所以下面的代码应该在x的结果元组中取第一个元素并将其转换为要使用的字符串。但是,当执行最后一行时,它告诉我它无法从元组转换为str。
for x in filelink:
print(x[0])
item = str(x[0])
oldpath = root.wgetdir + "\\" + root.website.get() + "\\" + item
print(oldpath)
if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + x, keyworddir + "\\" + item)
答案 0 :(得分:2)
这部分:
root.wgetdir + "\\" + root.website.get() + "\\" + x
right here ^
使用的是元组而不是item
。