![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
杨玉庆
这个作者很懒,什么都没留下…
展开
-
python 遍历目录
s = os.sep print s root = "D:" + s + "test" + s print root for rt,dirs,files in os.walk(root): for f in files: print f fname = os.path.splitext(f) print fname new =原创 2016-07-19 20:04:30 · 291 阅读 · 0 评论 -
python 替换文件固定字符串
try: fo = open(file_path, "r+") lines = fo.readlines() fo.seek(0) fo.truncate() for line in lines: fo.write(line.replace(old, new)) fo.close() return 1 except Exce原创 2016-08-02 19:10:27 · 628 阅读 · 0 评论 -
python 删除重复元素字典并在字典中加入重复元素次数
mylist = [{"b":1},{"b":1},{"b":1},{"b":1},{"c":2},{"c":2},{"b":1},{"b":1},{"b":1},{"c":2},{"c":2}] myset = [] for i in mylist: if not i in myset: myset.append(i) print myset for item2 in m原创 2016-12-08 10:50:27 · 4180 阅读 · 0 评论 -
Python 实现 英语 单词统计 和替换
def count_en(a, word): index = 0 times = 0 len_str = len(a) len_word = len(word) while True: index = a.find(word, index) if ind...原创 2018-12-27 16:48:16 · 1136 阅读 · 0 评论