摘要: # def func():name # def main(): # func() # main() # 排错信息从后往前看 ''' Traceback (most recent call last): File "/Users/jerry/code/test/selenium/oldboy/day2 阅读全文
posted @ 2025-02-19 21:03 尐少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: # item系列实现后,可以用 [] 去操作对象 class Item(): # pass def __getitem__(self, item): print('hello') # return 'test' return self.__dict__[item] def __setitem__(s 阅读全文
posted @ 2025-02-07 21:04 尐少 阅读(11) 评论(0) 推荐(0) 编辑
摘要: # __new__ 是调用类时第一个调用的方法; # 默认调用object基类的__new__方法,只在需要控制对象的创建过程时重写; # 必须返回实例(创建对象) class T(): _i = None def __new__(cls, **args, **kwargs): if cls._i 阅读全文
posted @ 2025-02-06 21:13 尐少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: #类的内置方法,也叫双下方法、魔术方法 # __call__ 实例化对象加上(), 可以触发这个类的 __call__ 方法,类似实例化时自动执行的__init__() class F1(): def __call__(self, *args, **kwargs): print('call') f1 阅读全文
posted @ 2024-12-03 20:20 尐少 阅读(5) 评论(0) 推荐(0) 编辑
摘要: #用于动态操作对象,但性能开销较大 class T(): name1 = 'test1' name2 = 'test2' def __init__(self, name4): self.name3 = 'test3' self.name4 = name4 def f1(self): print('f 阅读全文
posted @ 2024-11-25 21:01 尐少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: import logging logging.debug('debug') logging.info('info') # 正常执行时debug、info 日志不输出 logging.warning('waring') logging.error('error') logging.critical(' 阅读全文
posted @ 2024-11-20 21:00 尐少 阅读(21) 评论(0) 推荐(0) 编辑
摘要: # configparser import configparser config = configparser.ConfigParser() config['DB'] = { 'host': '10.10.10.10', 'port': 3306 } config['DEFAULT'] = { ' 阅读全文
posted @ 2024-11-20 20:58 尐少 阅读(2) 评论(0) 推荐(0) 编辑
摘要: # hash # hash() 将数据转换成一个数字的算法 """在同一次执行过程中,对同一个可hash的值进行计算得到的值是相同的,类似内存地址""" print(hash('123')) # 6690882297275263703 print(hash("123")) # 66908822972 阅读全文
posted @ 2024-11-18 21:25 尐少 阅读(4) 评论(0) 推荐(0) 编辑
摘要: Python 对 mysql 的函数支持有问题,执行包含sql函数的更新语句时可能会有问题的,导致锁表后无法操作。 如sql: UPDATE user_info set create_time = DATE_SUB(NOW(), INTERVAL 1 DAY) where user_id = '12 阅读全文
posted @ 2023-09-18 16:06 尐少 阅读(27) 评论(0) 推荐(0) 编辑
摘要: #正则 () [] [^] 表达式组 字符组 非字符组,只约束一个字符 """ 例: [0-9]#匹配一个数字 [a-zA-Z]#匹配一个字母,可以放多个范围 """ #元字符 . 匹配换行符外的任意字符 \w 匹配字母、数字、下划线 \s 匹配任意空白符 \d 匹配数字 \W \S \D 非 \t 阅读全文
posted @ 2022-09-22 20:11 尐少 阅读(20) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示