摘要: 1、定义 class Animal(): def __init__(self, __color, footNum, isCanSpeak): """ 动物属性 :param color: :param footNum: :param isCanSpeak: """ self.__color = __ 阅读全文
posted @ 2019-05-31 13:15 ChenHQ2048 阅读(398) 评论(0) 推荐(0) 编辑
摘要: 1、类的静态属性 @property #调用函数的时候,不用加括号 def getColor(self): return self.__color 2、类方法 @classmethod,只能访问类属性,不能访问实例属性。 class xxx(obj): @classmethod def getFoo 阅读全文
posted @ 2019-05-31 13:15 ChenHQ2048 阅读(380) 评论(0) 推荐(0) 编辑
摘要: 1、关键字传值 test(arg1 = x, arg2 = y) 2、参数组 def test(x, *args, **kwargs): //**字典,*列表 3、test(1,2,3,4,x=5) 同 test(1,*[2,3,4], **{'x':5}) 4、导入函数 import Hello 阅读全文
posted @ 2019-05-31 13:14 ChenHQ2048 阅读(96) 评论(0) 推荐(0) 编辑
摘要: import hashlib """ 用于加密相关的操作,3.x里代替了md5模块,主要提供SHA1,SHA224,SHA256,SHA384,SHA512,MD5算法 """ m = hashlib.md5() #m = hashlib.sha256() m.update("hello".enco 阅读全文
posted @ 2019-05-31 13:13 ChenHQ2048 阅读(71) 评论(0) 推荐(0) 编辑
摘要: import configparser ################################################################ #生成配置文件 """config = configparser.ConfigParser() config["DEFAULT"] 阅读全文
posted @ 2019-05-31 13:12 ChenHQ2048 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 日志配置 logging.basicConfig( level=logging.DEBUG, # 等级设置 filename="F:logger.log", filemode="a", format="[%(lineno)d][%(name)s] %(asctime)s: %(message)s " 阅读全文
posted @ 2019-05-31 13:05 ChenHQ2048 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1、模块的引用 1)import time 2)import time as tt 3) from Hello import hello1 as hh1, hello2 as hh2 4) from hello import hello1 //如果hello1是一个包,那么会调用hello下面的__ 阅读全文
posted @ 2019-05-31 13:02 ChenHQ2048 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 学习链接 https://www.runoob.com/regexp/regexp-tutorial.html 一 普通字符 普通字符包括没有显式指定为元字符的所有可打印和不可打印字符。这包括所有大写和小写字母、所有数字、所有标点符号和一些其他符号。 二 元字符 字符 描述 \ 将下一个字符标记为一 阅读全文
posted @ 2019-05-31 13:01 ChenHQ2048 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 装饰器是一个函数,用于装饰其他函数: 1、不修改原函数调用方式 2、不修改原函数代码 ###################################################################### import time def testNew(func): def w 阅读全文
posted @ 2019-05-31 12:59 ChenHQ2048 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 1、json.dump/json.dumps 将数据转换成json v = json.dump(variant) //将variant中单引号变成双引号,再将变量转字符串 eg: import json numbers = [2, 3, 5, 7, 11, 13] filename = 'numbe 阅读全文
posted @ 2019-05-31 12:59 ChenHQ2048 阅读(150) 评论(0) 推荐(0) 编辑