这对你有帮助。
def test_fun(val): x = 0 y = 1 z = 2 myList = [] if val in (x, y, z) and val == 0: myList.append("C") if val in (x, y, z) and val == 1: myList.append("D") if val in (x, y, z) and val == 2: myList.append("E") test_fun(2);