它在扫描字符串文字时说EOL,即使它以''结束”,我的代码中也发生过这种情况,这确实很烦人,因为我无法修复它。
import os
import shutil
'''VVV THIS LINE HERE IS SAY THIS VVV <--- here until the end of the screen '''
path = '\C:\Users\jyelo\Desktop\Test\'
names = os.listdir(path)
folder_name = ['PNG', 'JFIF']
for x in range(0,2):
if not os.path.exists(path+folder_name[x]):
os.makedirs(path+folder_name[x])
for files in names:
if ".png" in files and not os.path.exists(path+'PNG/'+files):
shutil.move(path+files, path+'PNG/'+files)
if ".jfif" in files and not os.path.exists(path+'JFIF/'+files):
shutil.move(path+files, path+'JFIF/'+files)
答案 0 :(得分:0)
问题是这一行:
path = '\C:\Users\jyelo\Desktop\Test\'
应该是:
path = 'C:\\Users\\jyelo\\Desktop\\Test\\'
更多信息:String literals
答案 1 :(得分:0)
错误部分: \' 反斜杠。您不能在此处使用反斜杠。它有一些特殊的含义,例如'\ n','\ t','\ r'等。
您还可以看到代码的重点。错误部分之后,每个文本均为橙色,这是一个错误符号。