我正在使用Mike Mcrath撰写的“Python In Easy Steps”一书,我遇到了用户输入项目的问题。我不断收到错误“编译单个语句时发现多个语句”。
user = input('Hello, my name is Hal. What is your name?:')
print( ' It is very nice to meet you',user)
我正在使用IDLE shell的3.4.3版本来测试我的代码。
答案 0 :(得分:2)
你需要逐个执行它们:
user = input('Hello, my name is Hal. What is your name?:')
它会要求输入然后:
print( ' It is very nice to meet you',user)
或创建一个Python脚本(.py),然后从终端exexute创建:
python filename.py
答案 1 :(得分:0)
试试这个:
print ('It is very nice to meet you %s' % user)
答案 2 :(得分:0)
print 'It is very nice to meet you %s' % user