better writing style for the following code

后端 未结 5 639
借酒劲吻你
借酒劲吻你 2021-01-28 09:42

I was wondering if someone could tell me the pythonic way to check out the following.

I have a 6 bit binary number and want to check with its decimal values. Using mathe

5条回答
  •  梦毁少年i
    2021-01-28 10:12

    Based on the somewhat vague information in the question and what I've been able to gather from the OP's comments, here's my guess:

    def func1(): pass
    def func2(): pass
    def func3(): pass
    #     ...
    def func62(): pass
    def func63(): pass
    
    if 0 < a < 64:
        globals()['func'+str(a)]()
    else:
        print 'a is out of range'
    

提交回复
热议问题