python读取文件时,删除重复行并计数
摘要:from collections import Counterwith open('a.txt', 'r+') as f: a = f.readlines() for i in range(len(a)): a[i] = a[i].strip().lower() b = [] a = dict(Co
阅读全文
python中的赋值、浅拷贝、深拷贝的区别
摘要:赋值: 可变类型:赋值前后id不会变,赋值后的数据会随源数据变化; 不可变类型:赋值前后id不会变,赋值后的数据不会随源数据变化; 浅拷贝(copy): 可变类型:copy前后id会变,可变类型中存储的可变类型和不可变类型复制前后id不变;源数据所包含的可变类型数据变化时,copy后数据会变(引用)
阅读全文
python3中os.renames()和os.rename()区别
摘要:renames源码:def renames(old, new): head, tail = path.split(new) # 作用是分割为两部分,head为路径,tail为文件名; if head and tail and not path.exists(head): # path.exists(
阅读全文