Python 2.7 IF函数的多个选项
所以我想写它,如果's'不等于1,2或3,那么它会打印错误。否则,如果它等于1、2或3,它将继续打印其他内容 这应该起作用:Python 2.7 IF函数的多个选项,python-2.7,if-statement,Python 2.7,If Statement,所以我想写它,如果's'不等于1,2或3,那么它会打印错误。否则,如果它等于1、2或3,它将继续打印其他内容 这应该起作用: if not (1 <= int(s) <= 3): print "ERROR" else: print "******" 如果不在[1,2,3]中,请尝试如果s不在[1,2,3]中它不起作用,我输入了1,2,3和4,每次都出现错误,因为s是字符串,如果int不在[1,2,3]中,请尝试 if not (1 <= int(s) &
if not (1 <= int(s) <= 3):
print "ERROR"
else:
print "******"
如果不在[1,2,3]中,请尝试如果s不在[1,2,3]中它不起作用,我输入了1,2,3和4,每次都出现错误,因为s是字符串,如果int不在[1,2,3]中,请尝试
if not (1 <= int(s) <= 3):
print "ERROR"
else:
print "******"