
python
Arvin.袁
这个作者很懒,什么都没留下…
展开
-
获取指定目录下所有py文件里的类名
import imp import os import re cls_name_list = [] def get_dir(path): try: file_list = os.listdir(path) except: print("the path is not dir") if file_list: for file in file_list: file = os.path.join(path, file原创 2020-06-01 14:13:04 · 1904 阅读 · 0 评论 -
python 线程卡死
使用os.system("kill -9 ")并不能杀死子线程 1.signal 信号处理机制(只能在主线程使用) 仅供参考 代码 import signal import time def _raise_error(self, sig, func=None): raise TimeoutError def test_time(): a = 5 time.sleep(a) print("...原创 2020-04-15 09:31:56 · 2319 阅读 · 0 评论 -
Unicode encode error ("\u" 问题解决方案)
```python a = "Mu\udcf1iz" b = a.encode("unicode-escape").decode() print('b: {}'.format(b)) c = a.encode(errors='replace').decode() print('c: {}'.format(c)) d = a.encode(errors='xmlcharrefreplace').d...原创 2020-03-31 14:57:43 · 1558 阅读 · 0 评论 -
使用sys.getrefcount()函数查看引用次数
import sys class Num: pass a = Num() print(sys.getrefcount(Num())) print(sys.getrefcount(a)) print(sys.getrefcount(3000)) print(sys.getrefcount(1)) print(sys.getrefcount(-1)) print(sys.getrefcount...原创 2019-01-15 13:35:50 · 9868 阅读 · 3 评论 -
虚拟环境
虚拟环境 虚拟环境的作用 在开发过程中, 当需要使用python的某些工具包/框架时需要联网安装 比如联网安装Flask框架flask-0.10.1版本 sudo pip install flask==0.10.1 提示:使用如上命令, 会将flask-0.10.1安装到/usr/local/lib/python2.7/dist-packages路径下 问题:如果在一台电脑上, 想开发多个不同的...原创 2019-04-12 14:15:54 · 264 阅读 · 0 评论 -
pip: unsupported locale setting
pip: unsupported locale setting 在终端输入 export LC_ALL=C原创 2019-04-12 18:03:15 · 147 阅读 · 0 评论