
python
大铭昕
这个作者很懒,什么都没留下…
展开
-
Python十大排序
冒泡排序两两比较,每次最小的元素往前冒,每轮选出一个当前最小的排在当前的最前面,n-1轮后全部有序。平均 O(n2) 最好情况:O(n) 基本有序 最坏:O(n2)def bs(alist): l = len(alist) for i in range(l): flag = 1; for j in range(l - i - 1): if alist[j] > alist[j + 1]:原创 2021-04-23 00:02:33 · 452 阅读 · 3 评论 -
【python】文件夹、文件名重命名
【python】文件夹、文件名重命名import os,shutilfile_path = r"E:\BaiduNetdiskDownload\04.1 Vue全套教程"def renameDirAndFile(file_dir): # 导入路径 for root, dirs, files in os.walk(file_dir): # 获得当前路径下的路径, 文件夹, 文件(list) for i in dirs: a = i原创 2021-01-16 16:33:13 · 490 阅读 · 0 评论 -
pycharm 设置代码块折叠,并添加注释方法
代码块折叠并注释1.方法2.效果3.其他折叠方式3.1 创建任意代码块1.方法Ctrl + Alt + t 后选择【region…endregion Comments】或者菜单栏【code】–>【Surround with】–>【region…endregion Comments】2.效果需要折叠原代码,添加region注释:折叠后效果3.其他折叠方式3.1 创建任意代码块【code】–>【folding】–>【Fold Selection/Rem原创 2020-12-22 17:07:50 · 11494 阅读 · 4 评论 -
【python文件操作】读取txt文件、复制文件
任务将require.txt中指定的文件,复制到指定目录包引入,路径定义import shutilpath_require = r'required.txt'path_copy = r'path_copy'path_paste = r'path_paste'requredlist = []1.读取txt文件,保存到数组listwith open(path_require, “r”) as f:# 1.获取文件中需要的文件名->listwith open(path_requi原创 2020-08-23 15:22:57 · 1872 阅读 · 0 评论