我在Windows上使用IDLE,当我在下面运行代码时,我得到错误。
mut ='F:\ Perl \ python \ Examples'
file_name = open(mut,'r')
追踪(最近一次通话):
文件“”,第1行,in
file_name = open(mut,'r')
PermissionErro enter code here
r:[Errno 13]权限被拒绝:'F:\ Perl \ python \ Examples'
'F:\ Perl \ python \ Examples'是我的'mut'文件所在的路径。
请帮助我很困惑?
答案 0 :(得分:1)
' /'可以非常愉快地在Windows上使用,并且更简单。
看起来Examples
是一个目录/文件夹 - 它应该是一个文件名。这就是你收到错误的原因。
请注意open()
返回文件句柄,而不是文件名。你期望这段代码做什么?
您是在寻找os.walk()
还是os.listdir()
?