我想连接列表中字符串的一部分,但出现类型错误
代码
l = [['----Italy', '----Spain', '----France']]
for n in l:
print("Hi "+n[4:]+" Country")
TypeError: can only concatenate str (not "list") to str
最佳答案
出于某种原因,你在一开始就列出了一个列表
_ = ['----Italy', '----Spain', '----France']
关于python - 只能连接 str 不能列表到 str,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67890130/