prompt = '\nTell me something , and I will repeat it back to you:' prompt += "\nEnter 'quit' to end the program.:" #这个位置亦可以写prompt = '\nTell me something , and I will repeat it back to you:\nEnter 'quit' to end the program.' #这样写太长了 #程序运行到这message没有空值 到while循环 判断message不等于quit 控制条输入 输出message message = '' while message != 'quit': message = input(prompt) print(message) #active为True标志 运行while循环 message为prompt 到if循环 若message为quit 更改active为False 否则输出message active = True while active: message = input(prompt) #输入quit是会输出两边原因就是在这个位置要 输出一遍然后在下边 才会更改active为false if message == 'quit': print ('这个是if') active = False else: print(message)
P106、107 Parrot.py个人理解
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.