摘要: os.path.split()将路径 path 拆分为一对,即 (head, tail),其中tail 是路径的最后一部分,而head 里是除最后部分外的所有内容。tail 部分不会包含斜杠,如果path以斜杠结尾,则tail 将为空。如果path中没有斜杠, head 将为空 os.path.sp 阅读全文
posted @ 2020-08-06 00:05 轩辕吊雷 阅读(294) 评论(0) 推荐(0) 编辑
摘要: for file in os.listdir(file_path): file_name = os.path.splitext(file)[0] 阅读全文
posted @ 2020-08-05 23:37 轩辕吊雷 阅读(11066) 评论(0) 推荐(2) 编辑
摘要: for file in os.listdir(path):执行语句 注:os.listdir(path) 方法用于返回指定的文件夹包含的文件或文件夹的名字的列表。 阅读全文
posted @ 2020-08-05 23:32 轩辕吊雷 阅读(484) 评论(0) 推荐(0) 编辑
摘要: 语法: shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False,dirs_exist_ok=False) 将以 src 为根起点的整个目录树拷 阅读全文
posted @ 2020-08-05 23:19 轩辕吊雷 阅读(7269) 评论(0) 推荐(0) 编辑
摘要: 语法: shutil.copy(src,dst,*,follow_symlinks=True) 将文件 src 拷贝到文件或目录 dst。src 和 dst 应为字符串。如果 dst 指定了一个目录,文件将使用 src 中 的基准文件名拷贝到 dst。返回新创建文件的路径。 如果follow_sym 阅读全文
posted @ 2020-08-05 23:16 轩辕吊雷 阅读(1536) 评论(0) 推荐(0) 编辑
摘要: str()将其他类型转化为字符串格式。 info = {'tom': 'cat', 'jerry': 'mouse'} print(type(info)) print(type(str(info))) int()将一个字符串或数字转换为整型。 str = '10' print(type(int(st 阅读全文
posted @ 2020-08-05 22:52 轩辕吊雷 阅读(1007) 评论(0) 推荐(0) 编辑
摘要: tup = ('hello', 1) print(type(tup)) 注:type和instance的区别 type() 不会认为子类是一种父类类型 instance会认为子类是一种父类类型 阅读全文
posted @ 2020-08-05 22:20 轩辕吊雷 阅读(3630) 评论(0) 推荐(0) 编辑
摘要: str = 'hello world' print(len(str)) 阅读全文
posted @ 2020-08-05 22:11 轩辕吊雷 阅读(532) 评论(0) 推荐(0) 编辑
摘要: 1、读写文件: open() 返回一个file object,最常用的有两个参数:open(filename, mode)。 f = open('workfile', 'w') 第一个参数是包含文件名的字符串。第二个参数是另一个字符串,其中包含一些描述文件使用方式的字符。 mode 可以是 'r' , 阅读全文
posted @ 2020-08-05 22:04 轩辕吊雷 阅读(1469) 评论(0) 推荐(0) 编辑
摘要: for语句用于对序列(例如字符串、元组或列表)或其他可迭代对象中的元素进行迭代。 语法: for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":" suite] 即 for 元素 in 迭代对象:执行语句 el 阅读全文
posted @ 2020-08-05 16:03 轩辕吊雷 阅读(475) 评论(0) 推荐(0) 编辑