complex if statement in python

后端 未结 5 908
我寻月下人不归
我寻月下人不归 2021-02-11 17:47

I need to realize a complex if-elif-else statement in Python but I don\'t get it working.

The elif line I need has to check a variable for this conditions:

5条回答
  •  孤独总比滥情好
    2021-02-11 18:31

    I think the most pythonic way to do this for me, will be

    elif var in [80,443] + range(1024,65535):
    

    although it could take a little time and memory (it's generating numbers from 1024 to 65535). If there's a problem with that, I'll do:

    elif 1024 <= var <= 65535 or var in [80,443]:
    

提交回复
热议问题