We'*_*ere 4 python file dir readfile
我创建了一个小的python脚本.有了这个,我试图读取一个txt文件但我的访问被拒绝解决为no.13错误,这是我的代码:
import time
import os
destPath = 'C:\Users\PC\Desktop\New folder(13)'
for root, dirs, files in os.walk(destPath):
f=open(destPath, 'r')
.....
Run Code Online (Sandbox Code Playgroud)
根据名称,我猜这destPath是一个目录,而不是一个文件.你可以在目录上做一个os.walk或一个os.listdir,但你不能open阅读它.你只能调用open一个文件.
也许你打算打电话open给一个或多个项目files
| 归档时间: |
|
| 查看次数: |
8223 次 |
| 最近记录: |