![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
「已注销」
系外行星的研究生
展开
-
【编码】Python下的os.system调用cmd命令时遇到中文出现乱码的解决方法
添加os.system(‘chcp 65001’)os.system('chcp 65001')os.system(cmd)原创 2019-04-30 14:18:37 · 3884 阅读 · 0 评论 -
【随行记录】当pip install下载慢时,使用跑p2p下载工具下载进行下载
输入命令,获得地址:复制以上地址,使用迅雷等下载工具下载原创 2019-07-21 14:57:01 · 323 阅读 · 0 评论 -
PyQt5安装
1.在线安装1.pip3 install PyQt52.pip3 install PyQt5-sip3.pip3 install PyQt5-tools2.离线安装1.PyQt5-5.11.3-5.11.2-cp35.cp36.cp37.cp38-none-win_amd64.whl,89.0Mb2.PyQt5_sip-4.19.15-cp37-none-win_amd64.whl,5...原创 2019-07-21 13:53:01 · 1315 阅读 · 0 评论 -
NLTK - 句子分割
NLTK安装:pip install nltknltk组件安装:install.pyimport nltknltk.download()句子分割:from nltk.tokenize import sent_tokenizetext = '''He was an old man who fished alone in a skiff in the Gulf Strea...原创 2019-06-30 13:31:54 · 6039 阅读 · 0 评论 -
拖拽单个文件至.py文件上作为输入文件
import sysdef main(): if len(sys.argv) == 2: f = sys.argv[1] print([f]) input('\n按任意键退出...') else: print('提示:只允许拖入单个文件') input('\n按任意键退出...')if __name__ =...原创 2019-06-29 13:49:55 · 2694 阅读 · 2 评论 -
Python数字格式化&保留小数位&进制转换
转载自菜鸟教程:数字格式化n = 3.1415926print(f’保留小数点后两位 >> [{n:.2f}]’)print(f’带符号保留小数点后两位 >> [{n:+.2f}]’)n = -1print(f’带符号保留小数点后两位 >> [{n:.2f}]’)print(f’不带小数 >> [{n:.0f}]’)n = 5pri...转载 2019-06-25 21:41:47 · 3884 阅读 · 0 评论 -
glob中的转义
glob模块中,如果目录名中含有[、],[、]是通配字符,需要对其进行转义。For a literal match, wrap the meta-characters in brackets. For example, ‘[?]’ matches the character ‘?’.my_dir = 'E:\\Downloads\\BaiduNetdiskDownload\\《三国演义》...原创 2019-06-14 10:29:46 · 777 阅读 · 0 评论 -
Python进度条 - progressbar2
from multiprocessing import Poolimport tqdmimport timedef _foo(my_number): square = my_number * my_number time.sleep(1) return square if __name__ == '__main__': l = list(range(1,...原创 2019-05-28 12:48:33 · 1409 阅读 · 0 评论 -
Python打开程序的两种方法以及区别
import os# 等待notepad窗口退出后再继续执行os.system('"notepad.exe"')print('已经退出了notepad')# 打开窗口后不等待窗口退出直接继续执行os.startfile('"notepad.exe"')print('不等待notepad退出直接继续执行')...原创 2019-05-18 13:48:31 · 527 阅读 · 0 评论 -
traceback
if __name__ == '__main__': import traceback try: main() except Exception: traceback.print_exc() #with open('error.txt', 'w', encoding='utf-8') as f: # ...原创 2019-05-18 00:52:01 · 476 阅读 · 0 评论 -
压缩当前路径 - 压缩备份
#!/usr/bin/python#Pythth2.7x, Python3x#coding: utf-8import osimport zipfileimport globimport timeimport win32con, win32api, osdef get_myfilelist(os_dir,wanted=1):‘’’os_dir=‘E:\BACKUP\BlueDic...原创 2019-05-17 20:12:20 · 176 阅读 · 0 评论 -
Python列表与迭代器
# 列表生成(数字迭代器转数字列表)l = [x+1 for x in range(10)]print(l)# 迭代器生成g = (x+1 for x in range(10))print(next(g))print(next(g))print(next(g))print(next(g))print(next(g))print(next(g))print(next...原创 2019-05-17 20:08:38 · 1359 阅读 · 0 评论 -
multiprocessing.Pool
from multiprocessing import Pooldef f(x): print(x*x)if __name__ == '__main__': p = Pool(5) p.map(f, [1, 2, 3, 4, 5, 6, 7, 8])转载 2019-05-17 20:06:07 · 457 阅读 · 0 评论 -
josn.dump, josn.load,格式化
import jsondata = {'key1':'value1','key2':'value2','key3':{'key4':'value4', 'key5':'value5'},}# Writing JSON datawith open('data.json', 'w') as f: json.dump(data, f)# Reading data ba...原创 2019-05-26 00:31:15 · 182 阅读 · 0 评论 -
有道翻译、小牛翻译Python[转载]
原文地址:https://blog.csdn.net/nunchakushuang/article/details/75294947import requestsimport timeimport randomimport hashlibdef YouDaoTranslator(eng="who are you?"): url = 'http://fanyi.youdao....转载 2019-05-25 21:28:53 · 1141 阅读 · 0 评论 -
josn格式化 - Python
import jsondicts = {'i': '"Top 10 College Dropouts."', 'from': 'AUTO', 'to': 'AUTO', 'smartresult': 'dict', 'client': 'fanyideskweb', 'salt': '15583685094363', 'sign': '6c267d0607194b4212bf38a5e254c...原创 2019-05-21 00:32:42 · 238 阅读 · 0 评论 -
Python, TableDict数据操作
参考文档:https://docs.python.org/3/library/csv.html#csv.writer# Python 3.7.ximport xlsxwriterimport xlrdimport csvclass TableDictData(object): table_list = [] # read '.xlsx' and '.csv' to table...原创 2019-10-10 16:18:21 · 421 阅读 · 0 评论