我有一本字典:
my_dictionary = {"058498":"table", "064165":"pen", "055123":"pencil"}
我遍历它:
for item in my_dictionary:
PDF = r'C:\Users\user\Desktop\File_%s.pdf' %item
doIt(PDF)
def doIt(PDF):
part = MIMEBase('application', "octet-stream")
part.set_payload( open(PDF,"rb").read() )
但我得到这个错误:
IOError: [Errno 2] No such file or directory: 'C:\\Users\\user\\Desktop\\File_055123.pdf'
它找不到我的文件。为什么它认为文件路径中有双反斜杠?