摘要: 第一种:内建方法sort() 可以直接对列表进行排序 用法: list.sort(func=None, key=None, reverse=False(or True)) 对于reverse这个bool类型参数,当reverse=False时:为正向排序;当reverse=True时:为方向排序。默 阅读全文
posted @ 2019-03-05 15:18 那种意境 阅读(274) 评论(0) 推荐(0) 编辑
摘要: 1、os.listdir():用于返回指定的文件夹包含的文件或文件夹的名字的列表。 如: dir ='F:/Home_01/img'#当前目录 filenames=os.listdir(dir)#filenames存储dir下的所有文件名。 注意:os.listdir()返回的文件名不一定是顺序的, 阅读全文
posted @ 2019-03-05 11:04 那种意境 阅读(1824) 评论(0) 推荐(0) 编辑
摘要: import os # 当前文件的路径 1、os.getcwd(); 2、os.path.realpath(__file__) # 当前文件的父路径 1、pwd=os.getcwd() os.path.abspath(os.path.dirname(pwd)+os.path.sep+".") ; 2 阅读全文
posted @ 2019-03-05 10:51 那种意境 阅读(705) 评论(0) 推荐(0) 编辑
摘要: 常用的两种方式: 1.python的OS模块。 OS模块调用CMD命令有两种方式:os.popen(),os.system(). 都是用当前进程来调用。 os.system是无法获取返回值的。当运行结束后接着往下面执行程序。用法如:OS.system("ipconfig"). OS.popen带返回 阅读全文
posted @ 2019-03-05 10:42 那种意境 阅读(1399) 评论(0) 推荐(0) 编辑