【发布时间】:2020-12-04 02:07:51
【问题描述】:
使用 python 代码,如何将字符串粘贴到用户输入中?
我想编辑一个文本,你有一行,用户输入已经有程序粘贴在上面的行,比如:
line = 'hello there'
input('')
然后,当你执行程序时,'hello there' 在你的输入中,你可以将它编辑成其他单词
【问题讨论】:
-
请显示一些实际代码。
标签: python python-3.x
使用 python 代码,如何将字符串粘贴到用户输入中?
我想编辑一个文本,你有一行,用户输入已经有程序粘贴在上面的行,比如:
line = 'hello there'
input('')
然后,当你执行程序时,'hello there' 在你的输入中,你可以将它编辑成其他单词
【问题讨论】:
标签: python python-3.x
像这样?
default_str = "Hello There"
user_input = default_str + input("{}".format(default_str))
【讨论】:
"{}".format(default_str) 写default_str的路很长
"Hello There" 可以编辑。