|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def find_file(original_road,target):
import os
import os.path
a = os.chdir(original_road)
for each_file in os.listdir(a):
if target == each_file:
print(os.getcwd() +os.sep + target)
if os.path.isdir(each_file):
find_file(each_file,target)
os.chdir(os.pardir)
original_road = input('请输入初始目录')
target = input('请输入目标文件')
find_file(original_road,target)
请输入初始目录C:\\Users\\11510
请输入目标文件1.txt
Traceback (most recent call last):
File "C:/Users/11510/Desktop/find_file.py", line 18, in <module>
find_file(original_road,target)
File "C:/Users/11510/Desktop/find_file.py", line 13, in find_file
find_file(each_file,target)
File "C:/Users/11510/Desktop/find_file.py", line 13, in find_file
find_file(each_file,target)
File "C:/Users/11510/Desktop/find_file.py", line 13, in find_file
find_file(each_file,target)
File "C:/Users/11510/Desktop/find_file.py", line 9, in find_file
for each_file in os.listdir(a):
PermissionError: [WinError 5] 拒绝访问。 我试着用管理员运行还是不行,如果是访问权限问题的话该怎么解决(我电脑只有C盘)
把文件放到桌面上,然后把工作目录切换到桌面(你把程序文件放在桌面也行)
|
|