- 博客(3)
- 收藏
- 关注
原创 python判断文件是否存在
import os filename = r'D:\data\表格\cc.txt'if os.path.exists(filename): message = 'OK, the "%s" file exists.'else: message = 'Sorry, I cannot find the "%s" file.'print (message % filename)
2022-02-23 23:57:52
1565
原创 python新建文件夹
import ospath = r'D:\data\表格' a = "j" os.mkdir(path + './'+a)结果目录下新建了一个文件名为“j”的文件夹
2022-02-23 23:25:30
560
原创 python读取文件夹下文件名
import osfilePath = r'D:\data\表格'file_list = os.listdir(filePath)for file in file_list: #读取原文件名 i = file #去除后缀 j = os.path.splitext(file)[0] print(i,j)
2022-02-23 23:16:22
1272
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人