我得到了路径
dire=os.path.abspath(".")
和
for fileName in filter(os.path.isfile, os.listdir(path=direc))
但dire
有C:\\
并向我发送下一个错误:
TypeError: listdir() takes no keyword arguments
当我打印dire
以查看下一个内容时打印:
C:\\user\\documents....
如何在\
中获取\\
而不是os.path.abspath(".")
?
答案 0 :(得分:1)
我假设repr
你的意思是s = 'C:\\'
s
>>> 'C:\\'
print(s)
>> C:\
。
\\
请注意,在打印时,既不会加倍'
也不会加TypeError: listdir() takes no keyword arguments
另一点是错误for fileName in filter(os.path.isfile, os.listdir(direc))
所以为什么不尝试:
for fileName in filter(os.path.isfile, os.listdir(path=direc))
而不是
setCaption()