会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
尐少
博客园
首页
新随笔
联系
订阅
管理
1
2
3
下一页
2025年8月26日
远程执行命令&黏包拆包
摘要: import subprocess # r = os.popen('pwd') r = os.popen('cmd') # 命令错误直接抛异常 print('11', r.read()) # shell = True 当成系统命令执行; stdout=subprocess.PIPE 获取命令执行结果
阅读全文
posted @ 2025-08-26 20:53 尐少
阅读(7)
评论(0)
推荐(0)
2025年5月14日
套接字--socket
摘要: socket.socket() 参数: family 指定网络协议,AF_INET IPv4(默认)、AF_INET6 IPv6 type 传输模式,SOCK_STREAM TCP(默认)、SOCK_DGRAM UDP proto 协议编号,通常自动匹配 fileno 文件描述符,用户低级操作或套接
阅读全文
posted @ 2025-05-14 21:03 尐少
阅读(14)
评论(0)
推荐(0)
2025年2月19日
异常处理
摘要: # 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 尐少
阅读(11)
评论(0)
推荐(0)
2025年2月7日
item
摘要: # 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 尐少
阅读(21)
评论(0)
推荐(0)
2025年2月6日
__new__、__del__
摘要: # __new__ 是调用类时第一个调用的方法; # 默认调用object基类的__new__方法,只在需要控制对象的创建过程时重写; # 必须返回实例(创建对象) class T(): _i = None def __new__(cls, **args, **kwargs): if cls._i
阅读全文
posted @ 2025-02-06 21:13 尐少
阅读(14)
评论(0)
推荐(0)
2024年12月3日
魔术方法
摘要: #类的内置方法,也叫双下方法、魔术方法 # __call__ 实例化对象加上(), 可以触发这个类的 __call__ 方法,类似实例化时自动执行的__init__() class F1(): def __call__(self, *args, **kwargs): print('call') f1
阅读全文
posted @ 2024-12-03 20:20 尐少
阅读(12)
评论(0)
推荐(0)
2024年11月25日
反射
摘要: #用于动态操作对象,但性能开销较大 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 尐少
阅读(13)
评论(0)
推荐(0)
2024年11月20日
logging
摘要: import logging logging.debug('debug') logging.info('info') # 正常执行时debug、info 日志不输出 logging.warning('waring') logging.error('error') logging.critical('
阅读全文
posted @ 2024-11-20 21:00 尐少
阅读(37)
评论(0)
推荐(0)
configparser
摘要: # configparser import configparser config = configparser.ConfigParser() config['DB'] = { 'host': '10.10.10.10', 'port': 3306 } config['DEFAULT'] = { '
阅读全文
posted @ 2024-11-20 20:58 尐少
阅读(19)
评论(0)
推荐(0)
2024年11月18日
hashlib
摘要: # hash # hash() 将数据转换成一个数字的算法 """在同一次执行过程中,对同一个可hash的值进行计算得到的值是相同的,类似内存地址""" print(hash('123')) # 6690882297275263703 print(hash("123")) # 66908822972
阅读全文
posted @ 2024-11-18 21:25 尐少
阅读(20)
评论(0)
推荐(0)
1
2
3
下一页
公告