检查是否有任何字符串列表在另一个字符串中

jak*_*ake 4 python python-3.x python-3.6

在python中,我正在尝试创建一个程序来检查字符串中是否有"数字",但我似乎得到了一个错误.这是我的代码:

numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]

test = input()

print(test)
if numbers in test:
    print("numbers")
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

TypeError: 'in <string>' requires string as left operand, not list
Run Code Online (Sandbox Code Playgroud)

我尝试更改数字numbers = "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",基本上删除了,[]但这也无效.希望我能得到答案; 谢谢 :)

Rom*_*est 6

使用内置的any()函数:

numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
s = input()

test = any(n in s for n in numbers)
print(test)
Run Code Online (Sandbox Code Playgroud)