我正在創建程式并且我想要慢速文本...但我的代碼有錯誤:
import sys
import time
def Hi(s):
for c in s '\n':
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(1./10)
Hi("hiiiiiiii")
`
def Hello():
print("heello")
def Sup():
print("ssuuuuuuuup")
Hi()
Hello()
Sup()
但是他給了我錯誤(他列印 hiii 并給我錯誤):
Traceback (most recent call last):
File "heheheheh i dont give :)", line 18, in <module>
Hi()
TypeError: Hi() missing 1 required positional argument: 's'
請幫我
uj5u.com熱心網友回復:
首先,學習如何提出一個好問題。如果您正在嘗試創建某種型別的打字效果,請查看此代碼。
import sys
import time
def printfunc(string):
for c in string '\n':
sys.stdout.write(c)
sys.stdout.flush()
time.sleep(1./10)
printfunc("hello world!")
uj5u.com熱心網友回復:
當你第二次呼叫 Hi() 時你不添加引數,如果你用 Hi("hello") 編輯它作業
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/351722.html
標籤:Python
