【问题标题】:What to use instead of or (Python) [duplicate]用什么代替或(Python)[重复]
【发布时间】:2026-02-22 21:30:02
【问题描述】:

if Sugar == "Yes" or "yes" or "ja" or "Ja": print(Msg1)

我怎样才能使它更短,而不是使用一打或的

【问题讨论】:

    标签: python if-statement


    【解决方案1】:

    你可以这样做:

    if Sugar in ["Yes", "yes", "ja", "Ja"]:
        print(Msg1)
    

    【讨论】: