python 输出中的“无”

我在周末开始学习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 car

stop - to stop the car

quit - to exit

help - to display this menu

>

None


长风秋雁
浏览 108回答 2
2回答

翻翻过去那场雪

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

芜湖不芜

修复第8行user_input = input('> ')您不需要编写 print 输入接受在获取输入时要显示的字符串。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python