如何在python中输入文本 [英] How to input text in python
本文介绍了如何在python中输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我昨天才开始尝试python,我想编写一些我可以输入文本的东西,然后按Enter键将添加一些东西
So I just started trying out python yesterday and I want to code something where I can input text then the something will be added once enter is pressed
例如:
如果我输入:Sam Smith 按回车后. . . 我会得到:欢迎山姆·史密斯
If I input: Sam Smith After pressing enter . . . I would get: Welcome Sam Smith
推荐答案
Python2.x:
>>> name = raw_input("Please enter the name..")
Please enter the name..Sam Smith
>>> name
'Sam Smith'
>>> print "Welcome " + name
Welcome Sam Smith
Python3.x:
>>> name = input("Please enter the name..")
Please enter the name..Sam Smith
>>> name
'Sam Smith'
>>> print("Welcome " + name)
Welcome Sam Smith
这篇关于如何在python中输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文