摘要: 需求: 某文本文件编码格式已知(如utf-8,GBK,BIG5),在python2.x和python3.x中分别如何读取该文件? 思路: 明确的一点: 在python2和python3中字符串的语义发生了变化 python2中的 str --> python3中的 bytes python2中的 u 阅读全文
posted @ 2020-07-11 17:33 Richardo-M-Lu 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 需求: 某个字典存储了一系列属性值, { 'lodDist':100.0, 'SmallCull':0.04, 'DistCull':500.0, 'trilinear':40 'farclip':477 } 在程序中,我们想以以下工整格式将其内容输出,如何处理? SmallCull:0.04 fa 阅读全文
posted @ 2020-07-11 16:49 Richardo-M-Lu 阅读(319) 评论(0) 推荐(0) 编辑
摘要: 需求: 某软件的Log文件,其中的日期格式为'yyyy-mm-dd': ..... 2016-05-23 10:59:26 status upacked python3-pip.all 2016-05-23 10:59:26 status half-configured python3-all 20 阅读全文
posted @ 2020-07-11 16:17 Richardo-M-Lu 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 需求: 某文件系统目录下有一系列文件: quicksort.c graph.py heap.java install.sh stack.cpp ... 编写程序给其中所有.sh文件和.py文件加上用户可执行权限 思路: 使用字符串的str.startswith()和str.endswith()方法 阅读全文
posted @ 2020-07-11 00:10 Richardo-M-Lu 阅读(133) 评论(0) 推荐(0) 编辑