python学习
qq_42303913
这个作者很懒,什么都没留下…
展开
-
python os.walk函数详解,以及如何得到文件上一级文件夹名
os.walk(path)返回的是一个三元组,以传入的参数path为起点,得到这个起点路径(root),这个起点下的所有的文件夹list(dirs),这个起点下的所有的文件list(files)三元组为(root,dirs,files)常用的操作:输出所有文件的完整路径os.path.join(root, file)把root跟文件名连接起来(注意不是字符串的简单拼接,因为两个中间可能有子文件夹)...原创 2021-11-23 16:55:35 · 3067 阅读 · 0 评论 -
python——defaultdict
http://kodango.com/?p=203转载 2019-03-02 16:35:23 · 82 阅读 · 0 评论 -
str.replace()没有替换
因为string类型是个常量,所以str.replace是不会改变str的要把它赋给一个新的string才可以s1 = str.replace()原创 2019-03-23 16:58:41 · 1256 阅读 · 0 评论 -
python创建n*m维矩阵
matrixA=[None]*nfor i in range(n): matrixA[i]=[0]*m原创 2019-04-20 23:42:38 · 16072 阅读 · 1 评论