会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
万金
博客园
首页
新随笔
联系
订阅
管理
2021年8月26日
【python】新建文件夹
摘要: import osos.mkdir('我的文件夹')#如果要要创建的文件夹存在,程序报错。#在创建文件夹之前,先判断创建的文件夹是否存在,不存在就创建新的。if not os.path.exists('我的文件夹2'): os.mkdir('我的文件夹2')#多级文件夹os.makedirsos.m
阅读全文
posted @ 2021-08-26 21:13 金涛拍岸
阅读(610)
评论(0)
推荐(0)
2021年8月25日
【python】os模块简介_路径操作
摘要: import osprint(os.path.join('F:\\万金鑫\Python\工程文件','2')) #告诉他路径 import osprint(os.getcwd()) #获得文件路径
阅读全文
posted @ 2021-08-25 22:12 金涛拍岸
阅读(38)
评论(0)
推荐(0)
【python】利用Python读写文件中的内容
摘要: with open('note.txt','r',encoding='utf-8')as f: print(f.readlines()) #读取! #写入with open('a.txt','w',encoding='utf-8') as a: #“w” a.write('你好?') a.write
阅读全文
posted @ 2021-08-25 22:11 金涛拍岸
阅读(52)
评论(0)
推荐(0)
【python】查询文件具体的详细信息
摘要: import osfor file in os.scandir(): print(file.stat())#sizi=字节(大小),ctime=创建时间,mtime=修改时间,atime=最近访问时间 #时间戳转换 import time import datetimeprint(time.ctim
阅读全文
posted @ 2021-08-25 22:11 金涛拍岸
阅读(101)
评论(0)
推荐(0)
【python】搜索指定要求的文件
摘要: #内置import oslst = os.listdir()print(lst)for I in lst: if I.endswith('.py'): # 在当前文件夹里寻找以”.py“结尾的文件 print(I)print('____________________________________
阅读全文
posted @ 2021-08-25 22:10 金涛拍岸
阅读(168)
评论(0)
推荐(0)
【python】创建临时文件和文件夹
摘要: #临时文件from tempfile import TemporaryFilefile=TemporaryFile('w+')file.write('杨老师好')file.seek(0)print(file.readlines())print(file.name)#查路径input('1234567
阅读全文
posted @ 2021-08-25 22:09 金涛拍岸
阅读(235)
评论(0)
推荐(0)
公告