[英]output error in printing string in python
to print the whole name but only single name is printing.打印全名,但只打印一个名称。
name = input(raw_input())
print ('Hello', name,'! You just delved into python.')
Input输入
Ross
Taylor
Output输出
Ross
Expected Output预期产出
Hello Ross Taylor! You just delved into python.
You can't do你不能做
name = input(raw_input())
You can either do你可以这样做
name = input()
or或者
name = raw_input()
Enter key or the newline is key for ending input to raw_input function. Enter 键或换行符是结束 raw_input 函数输入的键。 So either you write whole name in a single line as @Andreau suggested or you need to use some other method.因此,要么按照@Andreau 的建议将全名写在一行中,要么需要使用其他方法。 There is python package called Getch , that might help you in this regard.有一个名为Getch 的python 包,可以在这方面帮助你。
def print_full_name(a, b):
print("Hello", a, b + "!", "You just delved into python.")
if __name__ == '__main__':
first_name = input()
last_name = input()
print_full_name(first_name, last_name)
You will get the output while executing this program.您将在执行此程序时获得输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.