coolair
V2EX  ›  问与答

再请教一个 Python if 语句的写法

  •  
  •   coolair · Apr 26, 2018 · 1917 views
    This topic created in 2964 days ago, the information mentioned may be changed or developed.
    if A1:
        if A2 == X2:
            if B1:
                if B2 == Y2:
                    do_something()
                else:
                    print 'B2 must equal to Y2'
            else:
                do_something()
        else:
             print 'A2 must equal to X2'
    elif B1:
        if B2 == Y2:
            do_something()
        else:
            print 'B2 must equal to Y2'
    else:
        print 'Choose at least one between A1 and B1'
    
    2 replies    2018-04-26 16:41:11 +08:00
    pktangyue
        1
    pktangyue  
       Apr 26, 2018
    if not A1 and not B1:
    print 'Choose at least one between A1 and B1'
    return
    if A1 and A2 != X2:
    print 'A2 must equal to X2'
    return
    if B1 and B2 != Y2:
    print 'B2 must equal to Y2'
    return

    do_something()
    xmadi
        2
    xmadi  
       Apr 26, 2018 via iPhone
    。。。。 这个和语法没有关系了 纯粹是逻辑归纳能力不行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3752 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 04:34 · PVG 12:34 · LAX 21:34 · JFK 00:34
    ♥ Do have faith in what you're doing.