摘要: (1) 导入依赖库: import redis (2) 生成客户端连接:需要Redis的实例IP和端口两个参数: client = redis.StrictRedis(host=’127.0.0.1′, port=6379) (3) 设置和获取键值 client.set(key, "python-r 阅读全文
posted @ 2020-08-13 14:18 diracy 阅读(433) 评论(0) 推荐(0)
摘要: # 连接数据库connect("数据库名") # mongodb 没有配置用户权限,用的默认设置。connect("数据库名", host="主机名", port=端口号, username=, password=) # 要验证的方式# 定义表# 定义 类,继承自Document类名,就是mongo 阅读全文
posted @ 2020-08-13 14:11 diracy 阅读(380) 评论(0) 推荐(0)
摘要: #1.连接MongoDB# 使用pymongo的第一步首先是连接Client来使用服务:from pymongo import MongoClientclient = MongoClient()#2.连/建 数据库 ( my_db是数据库名称,如果没有会自动创建)# 在MongoDB中一个实例能够支 阅读全文
posted @ 2020-08-13 13:59 diracy 阅读(104) 评论(0) 推荐(0)
摘要: # class Cou:# __discount=0.8# def __init__(self):# self.price=5# self.price=self.price*self.__discount# @property# def nowdiscount(self):# print(Cou._ 阅读全文
posted @ 2020-08-11 00:54 diracy 阅读(140) 评论(0) 推荐(0)
摘要: class Student: def __init__(self,name,lesson): self.name=name self.lesson=lesson def choice_lessons(self): pass def scan_lessons(self): pass def check 阅读全文
posted @ 2020-08-09 16:50 diracy 阅读(178) 评论(0) 推荐(0)
摘要: class A: def __init__(self,name,age): self.name=name self.__age=age @property def age(self): print(self.__age) @age.setter def age(self,reage): self._ 阅读全文
posted @ 2020-08-09 11:00 diracy 阅读(172) 评论(0) 推荐(0)
摘要: # 普通的类# 抽象类 是一个开发的规范 约束它的所有子类必须实现一些和它同名的方法# 支付程序 # 微信支付 url连接,告诉你参数什么格式 # {'username':'用户名','money':200} # 支付宝支付 url连接,告诉你参数什么格式 # {'uname':'用户名','pri 阅读全文
posted @ 2020-08-09 10:10 diracy 阅读(133) 评论(0) 推荐(0)
摘要: import sysclass Authentic: def __init__(self,name,age): self.name = name self.age = age def register(self): print('注册') def login(self): print('登录')l 阅读全文
posted @ 2020-08-09 09:40 diracy 阅读(169) 评论(0) 推荐(0)
摘要: import pickleclass Mypickle: def __init__(self,path): self.file = path def dump(self,obj): with open(self.file, 'ab') as f: pickle.dump(obj, f) def lo 阅读全文
posted @ 2020-08-05 15:34 diracy 阅读(173) 评论(0) 推荐(0)
摘要: import jsonclass A: def __init__(self,type,num): self.type=type self.num=num def welcome(self): print('how are you!')class My_json: def __init__(self, 阅读全文
posted @ 2020-08-05 15:30 diracy 阅读(497) 评论(0) 推荐(0)