为了账号安全,请及时绑定邮箱和手机立即绑定

python 输出中的“无”

python 输出中的“无”

长风秋雁 2023-09-19 15:02:28
我在周末开始学习Python,每当我要求用户输入时,在打印内容之后,输出中总是有一个None。代码:    print('start - to start the car')    print('stop - to stop the car')    print('quit - to exit')    print('help - to display this menu')        contador = 1    while contador == contador:        user_input = input(print('> '))        user_input.upper()        if user_input == 'HELP':            print('start - to start the car')            print('stop - to stop the car')            print('quit - to exit')            print('help - to display this menu')        elif user_input == 'START':            print('Car started... Ready to go!!')        elif user_input == 'STOP':            print('Car stopped!')        elif user_input == 'QUIT':            break        else:            print('Command not identified!')输出:start - to start the carstop - to stop the carquit - to exithelp - to display this menu>None
查看完整描述

2 回答

?
翻翻过去那场雪

TA贡献2065条经验 获得超13个赞

input(print('> '))显示None因为print()返回None. 只需执行input('> '),这将打印正确的内容。



查看完整回答
反对 回复 2023-09-19
?
芜湖不芜

TA贡献1796条经验 获得超7个赞

修复第8行

user_input = input('> ')

您不需要编写 print 输入接受在获取输入时要显示的字符串。


查看完整回答
反对 回复 2023-09-19
  • 2 回答
  • 0 关注
  • 66 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信