简体   繁体   English

输入功能不显示,打印时为“空白”

[英]Input function don´t show and is "blank" in print

I´m new to python and uses the latest version of 3.7 on mac 64bit.我是 python 新手,在 64 位 mac 上使用最新版本的 3.7。 When put in following code and run model, my name don´t show: " Its good to meet you, (blank)!"输入以下代码并运行模型时,我的名字不显示:“很高兴认识你,(空白)!”

What is wrong?怎么了?

print('Hello World')
print('Whats your name?')
myname = input ('Alexander') 
print('Its good to meet You,' + myname +'!')

The input function expects user input while the function is running, eg input() and then you would type your name in the terminal. input 函数在函数运行时需要用户输入,例如input() ,然后您将在终端中输入您的姓名。 "Alexander" should be shown in the terminal with your current code. “亚历山大”应显示在终端中,并带有您当前的代码。 Try尝试

print('Hello World')
myname = input('Whats your name?') 
print('Its good to meet You,' + myname +'!')

Then type "Alexander" in the command prompt然后在命令提示符中输入“Alexander”

More info here更多信息在这里

The input function is used to let the user inputs string after the start. input 函数用于让用户在开始后输入字符串。 You have to type something when it sais alexandre当它说 alexandre 时,你必须输入一些东西

it seems you put a space after input function.看来你在输入函数后放了一个空格。 instead of代替

print('Whats your name?')
myname = input ('Alexander')

Try this尝试这个

myname = input("Whats your name? ")

and after running this code when this ask for name just type in your name运行此代码后,当此要求输入您的姓名时,只需输入您的姓名

the comple code will look like this完整的代码看起来像这样

print('Hello World')
myname = input("Whats your name? ")
print('Its good to meet You, {} !'.format(myname))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM