gpt4 book ai didi

python - 将文本行与第二行中的用户输入合并

转载 作者:太空宇宙 更新时间:2023-11-03 20:38:52 25 4
gpt4 key购买 nike

如何使用户输入与之前的文本打印在同一行?

print('Enter the rainfall amount for month', months, end='')
monthly_rainfall=float(input(': '))

期望的结果:

Enter the rainfall amount for month 1: 1
<小时/>

实际结果:

Enter the rainfall amount for month 1
: 1

最佳答案

尝试使用input()代替。这应该会给你一个更简单的解决方案。

monthly_rainfall = float(input('Enter rainfall amount for month {0}: '.format(months)))

关于python - 将文本行与第二行中的用户输入合并,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56980778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com