Linux终端执行Python脚本与Id不同

2024-09-30 01:22:39 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我写了一个程序,像旧的点阵打印机一样,一个字符一个字符地打印歌曲。当我在空闲状态下运行这个程序时,它可以运行并且工作正常,但是当我从Linux终端调用程序时,文本是逐行打印的,而不是逐字符打印的,这确实会影响程序的整体效果和要点。 我能做些什么来解决这个问题吗?或者是终端将如何使用它。谢谢

#!/usr/bin/python3
import time

print ("<<<<<<<<<<<<<<<<<<<<<<< Portal Song Printer >>>>>>>>>>>>>>>>>>>>>>>")
ans = input("Still Alive(1) or Want You Gone(2):\n")
if ans == "1":
    song = """This was a triumph\nI'm making a note here: HUGE SUCCESS\nIt's hard
to overstate my satisfaction\n\nAperture Science\nWe do what we must because we can
For the good of all of us, except the ones who are dead\n\nBut there's no sense
crying over every mistake\nYou just keep on trying 'till you run out of cake
And the Science gets done\nAnd you make a neat gun\nFor the people who are still alive
\nI'm not even angry\nI'm being so sincere right now\nEven though you broke my
heart and killed me\n\nAnd tore me to pieces\nAnd threw every piece into a fire\nAs
they burned it hurt because I was so happy for you\n\nNow these points of data make
a beautiful line\nAnd we're out of beta, we're releasing on time\nSo I'm GLaD I got
burned\nThink of all the things we learned\nFor the people who are still alive"""
    print ("<<<<<<<<<<<<<<<<<<<<<<< Still Alive >>>>>>>>>>>>>>>>>>>>>>>\n")

elif ans == "2":
    song = """Well, here we are again\nIt’s always such a pleasure
Remember when you tried\nTo kill me twice?\n\nOh, how we laughed and laughed
Except I wasn’t laughing\nUnder the circumstances\nI’ve been shockingly nice
\nYou want your freedom? Take it\nThat’s what I’m counting on\nI used to want you dead, but
Now I only want you gone\n\nShe was a lot like you\n(Maybe not quite as heavy)
Now little Caroline\nIs in here too\n\nOne day they woke me up\nSo I could live forever
It’s such a shame the same\nWill never happen to you\n\nYou’ve got your short, sad life left
That’s what I’m counting on\nI’ll let you get right to it\nNow I only want you gone
\nGoodbye, my only friend\nOh, did you think I meant you?\nThat would be funny
If it weren’t so sad\n\nWell, you have been replaced\nI don’t need anyone now
When I delete you, maybe\nI’ll stop feeling so bad\n\nGo make some new disaster
That’s what I’m counting on\nYou’re someone else’s problem\nNow I only want you gone
\nNow I only want you gone\nNow I only want you gone..."""
    print ("<<<<<<<<<<<<<<<<<<<<<<< Want You Gone >>>>>>>>>>>>>>>>>>>>>>>\n")

for c in song:
    print(c, end="")
    time.sleep(.05)

Tags: oftheto程序youonlyonwhat

热门问题