假设我有一个字符列表['h','e','l','l','o']
,我想查看字符列表是否与字符串'hello'
匹配,我该如何做?该列表需要完全匹配字符。我想过使用类似的东西:将字符串与字符列表进行比较
hList = ['h','e','l','l','o']
hStr = "Hello"
running = False
if hList in hStr :
running = True
print("This matches!")
但这不起作用,我会怎么做这样?
啊谢谢,现在看起来很明显是''。加入(hList)将列表转换为字符串:P – RonB7