在路径= bla bla行上,它在扫描字符串文字时显示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)
问题出在这一行:
path = '\C:\Users\jyelo\Desktop\Test\'
应该是:
path = 'C:\\Users\\jyelo\\Desktop\\Test\\'
更多信息:String literals
我是一名优秀的程序员,十分优秀!