【发布时间】:2021-08-21 00:41:40
【问题描述】:
我一直在做一些编码并尝试其他写出文本的方式。
def printOut(text):
for char in text:
sleep(0.3)
sys.stdout.write(char)
printOut("hello")
printout("hi")
这运行在同一行而不是下一行。谁能告诉我我做错了什么?
【问题讨论】:
-
你不写换行符。
-
为什么不直接使用内置的
print函数呢? -
相关:stackoverflow.com/q/3263672/2745495。特别是这个答案:stackoverflow.com/a/3263733/2745495(“使用标准输出时,您需要自己将对象转换为字符串(例如通过调用“str”)并且没有换行符。 ")
标签: python