>> 为什么使-6ren">
gpt4 book ai didi

python - python 3.5 中 print 中的 end 参数在交互模式下显示提示前的结果

转载 作者:太空宇宙 更新时间:2023-11-03 16:55:45 24 4
gpt4 key购买 nike

在 python 3.5.1 中,当以交互模式运行下面的语句时

print ("My", "name", "is", end = 'done')

输出是:

My name isdone>>>

为什么使用 end 时结果显示在提示之前?

最佳答案

问题在于,默认情况下,打印函数的 end 参数设置为 '\n'。在您的代码中,您已覆盖该内容,因此指针不会移动到下一行。要解决此问题,只需替换

end = 'done'

end = 'done\n'

关于python - python 3.5 中 print 中的 end 参数在交互模式下显示提示前的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35433078/

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