waitforlove 发表于 2018-2-11 17:42:07

小问题不懂,求解惑

prompt = '''
|--- 新建用户:N/n ---|
|--- 登录账号:E/e ---|
|--- 推出程序:Q/q ---|
|--- 请输入指令代码:'''

    while True:
      chosen = False
      while not chosen:
            choice = input(prompt)
            if choice not in 'NnEeQq':
                print('您输入的指令代码错误,请重新输入:')
            else:
                chosen = True

请问这 while not chosen: 这怎么理解


新手·ing 发表于 2018-2-11 17:43:17

while not chosen:
相当于
while chosen == Flase

waitforlove 发表于 2018-2-11 17:50:00

新手·ing 发表于 2018-2-11 17:43
相当于

是取反的意思吧

waitforlove 发表于 2018-2-11 17:53:00

waitforlove 发表于 2018-2-11 17:50
是取反的意思吧

chosen = Flase
while 取反(chosen)=true
执行循环
这样理解可以不{:10_254:}

新手·ing 发表于 2018-2-11 17:55:18

waitforlove 发表于 2018-2-11 17:53
chosen = Flase
while 取反(chosen)=true
执行循环


可以可以。
等于号要两个哦。

新手·ing 发表于 2018-2-11 17:58:07

给个最佳呗

waitforlove 发表于 2018-2-11 18:01:12

新手·ing 发表于 2018-2-11 17:55
可以可以。
等于号要两个哦。

你的意思not chosen是个条件语句 返回true 或false
chosen=1
while not chosen: #whlile chosen==1:    相等就循环
{:10_250:}明白了

新手·ing 发表于 2018-2-11 18:02:41

waitforlove 发表于 2018-2-11 18:01
你的意思not chosen是个条件语句 返回true 或false
chosen=1
while not chosen: #whlile chosen==1:    ...

满意就给最佳呗。
,,,你这里可不是1.
页: [1]
查看完整版本: 小问题不懂,求解惑