随笔分类 - python
摘要:https://blog.csdn.net/wanger5354/article/details/122118712https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html 1.2 连接数据库 要使用PyMongo操作Mong
阅读全文
摘要:python rsa加解密代码: 只适用python3: import base64 from Crypto.Cipher import PKCS1_v1_5 from Crypto import Random from Crypto.PublicKey import RSA # 生成密钥对 def
阅读全文
摘要:默认字典defaultdict defaultdict是对字典的类型的补充,他默认给字典的值设置了一个类型。 class defaultdict(dict): """ defaultdict(default_factory[, ...]) --> dict with default factory
阅读全文
摘要:有序字典orderedDict orderdDict是对字典类型的补充,他记住了字典元素添加的顺序 class OrderedDict(dict): 'Dictionary that remembers insertion order' # An inherited dict maps keys t
阅读全文
摘要:计数器counter Counter是对字典类型的补充,用于追踪值的出现次数。 ps:具备字典的所有功能 + 自己的功能 c = Counter('abcdeabcdabcaba') print c 输出:Counter({'a': 5, 'b': 4, 'c': 3, 'd': 2, 'e': 1
阅读全文
摘要:集合set set是一个无序且不重复的元素集合 class set(object): """ set() -> new empty set object set(iterable) -> new set object Build an unordered collection of unique e
阅读全文
摘要:元组tuple tuple:(11,22,33)、('wupeiqi', 'alex') class tuple(object): tuple() -> empty tuple tuple(iterable) -> tuple initialized from iterable's items If
阅读全文
摘要:字典dict dict:{'name': 'wupeiqi', 'age': 18} 、{'host': '2.2.2.2', 'port': 80]} class dict(object): dict() -> new empty dictionary dict(mapping) -> new d
阅读全文
摘要:列表list list:[11,22,33]、['wupeiqi', 'alex'] class list(object): list() -> new empty list list(iterable) -> new list initialized from iterable's items d
阅读全文
摘要:浮点型float class float(object): float(x) -> floating point number Convert a string or number to a floating point number, if possible. def as_integer_rat
阅读全文
摘要:字符串string class str(basestring): """ str(object='') -> string Return a nice string representation of the object. If the argument is a string, the retu
阅读全文
摘要:python 一切事物都是对象,对象基于类创建 类:(列表)功能集合 查看对象相关成员:var,type,dir 参考文档 http://www.cnblogs.com/wupeiqi/articles/5115190.html 一、整数 int int(x=0) -> int or long in
阅读全文
摘要:参考文档:http://www.cnblogs.com/wupeiqi 1、交互式输入: input()用法: python3: var=input("please input a varible:") print(var) eval():取出变量中的值 a=5 eval("a") > 5 pyth
阅读全文
摘要:函数 定义一个函数:def 在函数中描述函数: 函数的文档字符串用于描述函数:"""描述的内容""",可以不遵循缩进规则; 通过函数中的名称(._ _doc_ _)引用。 添加注释:#用于注释,将注释保持在同样的缩进级别; 可以通过dir()可以看到一个对象的所有属性; type()函数可以显示一个
阅读全文
摘要:决策 1、根据True和False做出决策 ==,!=,>,<,>=,<= 比较两个值是否相等,比较两个字符串的内容是否相同: 序列:序列也可用双等号比较:每个序列中同一位置的每个元素都相同,则两个序列相等;若序列中的元素相同,但顺序不同,则两个序列不相等。 字典:字典中的每个键和值必须与另一字典中
阅读全文
摘要:一、字符 1、字符串: 单引号(‘),双引号("),三引号('")是等价的 2、print函数:在屏幕上打印文本 转义字符:\: \n:换行 串联两个字符串:当需要把两个或多个字符串连在一起时: 1>用加号+:“John" + "Everyman" >JohnEveryman 2>不用加号+:“Jo
阅读全文