如下:
A = [1, 2, 3]B = [4, 5, 6]text = input("请输入:")x = Falsey = Falsefor s in text: if int(s) in A: x = True if int(s) in B: y = Trueif x == True and y == True: print("OK")