鱼C论坛

 找回密码
 立即注册
分享 python3将help命令打印的内容保存到文件中
JessiFly 2024-1-20 11:01
需要重定向默认的标准输出流stdout import sys #对输出流做备份 back = sys.stdout filepath = 'out.txt' with open(filepath,'w') as f: sys.stdout = f help(str) #还原输出流 sys.stdout = back 打包成函数: import sys def help_to_file(filepath ...
个人分类: Python|62 次阅读|0 个评论
分享 tqdm模块显示进度条
JessiFly 2021-11-5 11:09
Python版本3.6.4 以下代码在VS code和IDLE中,进度条都不能单行显示。 from time import sleep from tqdm import tqdm bar = tqdm(range(1,20)) for each in bar: bar.set_description('Processing %s' %each) sleep(1) 加入ncols参数后在VS code中可正常单行显示,而IDL ...
个人分类: Python|174 次阅读|0 个评论
分享 Python3中星号的打包和range函数的配合
JessiFly 2019-7-2 19:05
print(range(1,5)) range(1, 5) print(*range(1,5)) 1 2 3 4 print函数 只支持*args,不支持**kwargs。 def print(self,*args,sep=' ',end='\n',file=None)
个人分类: Python|473 次阅读|0 个评论

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-7-27 16:53

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部