2021-05-18

os.listdir(path)将返回文件名字符串。
os.path.getsize(‘c\windows\system1\calc.exe‘)
xxx#程序的字节。
os.listdir(c:\windows\system 1)
(a,b,c,d)#c盘中的文件名

os.path.exist(path)用于检测文件是否存在
os模块没了

读写文件
1用Open函数。
2用file对象的read()或write()
用TextEdit创建一个A.txt
1 hello File=open(c:\你的计算机用户名\A.txt)
2 read
hello content=hello File.read()
hello content
‘A’
写入
hellofile=open(A.txt)
A File.write(hello world)
File.close()
xxx
File=open(A.txt)
xxx
File.close()
File = ipen(A.txt)
content = AFile.read()
A File.close
print (content)#先以写入模式,打开A.txt

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值