嗨我正在製作一個腳本,只是爲了好玩,我遇到了一個小問題。使用def的Python 3.2.0
我的代碼需要工作的方式,我需要回想一下腳本,但要做到這一點,它需要在召回另一個腳本時被召回。
我知道有點困惑,但它使腳本更有意義。這是我的代碼:
# Importing time and date...
import time
import datetime
# Defining ans() and name().
def ans():
print("Are you sure your name is Vegas?")
time.sleep(2)
print("Well I'm not so sure.")
time.sleep(1)
print("You'll have to prove it.")
time.sleep(1)
print("Which typewriter brand does Vegas have?")
print("1. Sizzix")
print("2. Royal")
print("3. Alivetti")
print("4. Smith-Corona")
ans=input(">")
if ans == "4":
print("Correct....")
else:
print("Incorrect! You are not Vegas! Liar!")
name()
def name():
name=0
print("Detecting...")
time.sleep(2)
name == input("Is your name Vegas? (Y or N) >")
if name == "Y":
ans()
if name == "N":
name()
# Now for the actual script. This prints the time and then runs the code in name().
now = datetime.datetime.now()
print(now, " --That is the time.")
name()
# If name == Y, then it's supposed to go to ans() and run the code there.
# Instead it goes through the code inside name() and then stops.
所有的大字體只是我用作筆記(#)的東西。我正在爲我的朋友製作這個腳本,名字叫拉斯維加斯,這就解釋了這一點。
您的輸入是什麼?你能附上你給出的輸入和你在控制檯上看到的輸出嗎? – SMA
感謝球員真的幫助:) – boatofturtles