Python input error

后端 未结 4 695
[愿得一人]
[愿得一人] 2021-01-14 12:10

I\'m running python 2.7.10 on Mac OSX 10.9.5m and it\'s not working. Here\'s the code:

# YourName.py
name = input(\"What is your name?\\n\")
print(\"Hi, \",          


        
4条回答
  •  被撕碎了的回忆
    2021-01-14 12:35

    Input tries to evaluate if the given string as a program. For a string alone use raw_input. Or you have to quote the string you had on input to allow python to interpret it as a string. For example:

    "Ella"
    

提交回复
热议问题