“2021年1月”存档文章有21

python多线程中的setDaemon

若在主线程中创建了子线程,当主线程结束时根据子线程daemon(设置thread.setDaemon(True))属性值的不同可能会发生下面的两种情况之一:如果某个子线程的daemon属性为False,主线程结束时会检测该子线程是否结束,如果该子线程还在运行,则主线程会等待它完成后再退出;如果某个子线程的daemon属性为True,主线程运行结束时不对这个子线程进行检查而直接退出,同时所有daem...

python字符串相关操作总结

最近在python程序中,遇到使用subprocess读取系统命令相关操作,涉及到大量的字符串操作,对python字符串操作进行总结。bytes装换成str:result.stdout.decode('utf-8')result.stdout是bytes数据类型,转成str类型。字符串查找:get_time_result.index('time')python 的index方法是在字符串里查找子串...

TypeError: can only concatenate str (not "int") to str

在调试程序的时候出现如下错误:TypeError: can only concatenate str (not "int") to str出现问题的原因:只能将str(而不是“ int”)连接到str,具体错误代码如下:for item in range(int(start_ip), int(end_ip + 1)):start_ip和end_ip都是str数据类型,问题出现在:end_ip+1,...

python logging.warn 和 logging.warning 的区别

logging.warn从Python 3.3开始已弃用,您应该使用logging.warning。在此之前的Python 3.3,logging.warn并且logging.warning是相同的功能。参考资料:1、What's the difference between logging.warn and logging.warning in Python?

python range

python range语法:range(start, stop, step)start 开始数字end 结束数字,不包括结束的数step 步数,默认为1下面是代码示例:x = range(3, 6) for n in x: print(n)结果:3 4 5

Specify the 'foreign_keys' argument

在处理SQLAlchemy模型的时候,出现了如下错误:sqlalchemy.exc.InvalidRequestError: One or more mappers failed to initialize - can't proceed with initialization of other mappers. Triggering mapper: 'mapped class CoCode->c...

appears to be a non-schema 'sqlalchemy.sql.colu mn()' object

在使用SQLAlchemy件库的过程中,出现如下警告:SAWarning: Attribute 'continent_name_en' on class <class 'app.models.IPCrawlerContinent'> appears to be a non-schema 'sqlalchemy.sql.column()' object; this won't be part of ...

github md文件shell命令高亮

最近代码提交到github,再md文件中需要写部署方式,涉及到shell命令,再github中shell命令写法如下:```console foo@bar:~$ whoami foo ```最后显示效果如下: