如何将输入函数“移动”到字符串中?基本上我目前有这个:
Age = 11
sentence1 = input("Tomorrow I will be ___ years old!")
while sentence1 != Age:
print("Nope, that's not it! Guess again!")
sentence1 = input("Tomorrow I will be ___ years old!")
当我运行该程序时,输入或“光标”总是出现在句子的结尾,但是我希望它在句子中的“ be”之后开始。
答案 0 :(得分:0)
尝试使用此方法将光标向后移动15个位置。 代码:
Age = 11
sentence1 = input("Tomorrow I will be ___ years old! \x1B[15D")
while sentence1 != Age:
print("Nope, that's not it! Guess again!")
sentence1 = input("Tomorrow I will be ___ years old! \x1B[15D")
您可以根据要放置光标的位置数来调整数字。