字符串包含两个数字中的任意一个



如果一个特定的列表项包含几个数字中的一个,我想执行if条件:

if firststring[1] == 100 or 40 or 80 or 67:
print('hallo')

这个代码有意义吗?

您可以使用python的in:

if firststring[1] in (100, 40, 80, 67):
print('hi =)')

最新更新