gpt4 book ai didi

python - 即使在关闭时也扫描字符串文字时 EOL

转载 作者:太空宇宙 更新时间:2023-11-03 19:48:04 26 4
gpt4 key购买 nike

在路径= 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

关于python - 即使在关闭时也扫描字符串文字时 EOL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60016030/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com