【问题标题】:Is there a way to paste a string into a user input using code? [duplicate]有没有办法使用代码将字符串粘贴到用户输入中? [复制]
【发布时间】:2020-12-04 02:07:51
【问题描述】:

使用 python 代码,如何将字符串粘贴到用户输入中?

我想编辑一个文本,你有一行,用户输入已经有程序粘贴在上面的行,比如:

line = 'hello there'

input('')

然后,当你执行程序时,'hello there' 在你的输入中,你可以将它编辑成其他单词

【问题讨论】:

标签: python python-3.x


【解决方案1】:

像这样?

default_str = "Hello There"
user_input = default_str + input("{}".format(default_str))

【讨论】:

  • "{}".format(default_str)default_str的路很长
  • 我希望"Hello There" 可以编辑。
  • @DominicRhowelEmbate 我明白了。我会在一分钟内删除。请看原帖的评论。这似乎是一个可能的答案!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-27
  • 1970-01-01
  • 2017-12-10
  • 1970-01-01
  • 2019-10-13
  • 2023-02-24
相关资源
最近更新 更多