这个简单的Python脚本不起作用。
import time
import random
callingcard = ('BootsOnTheGround', 'TitanBaseCamp', 'TitanFacility',
'TitanicStorm', 'TitanicCanyon', 'TitanSandstorm', 'ToTheShip',
'AsteroidMines', 'TheSteelDragon', 'C6Assembly', 'C12Patrol')
weapons = ('Rack-9', 'Karma-45', 'NV-4', 'R3K', 'KBAR- 32', 'Trencher', 'Type-2', 'Volk', 'ERAD', 'FHR40', 'RPR Evo', 'KBS Longbow', 'DMR-1', 'Widowmaker', 'Banshee', 'DCM-8', 'Reaver', 'RAW', 'Mauler', 'Titan', 'EMC', 'Oni', 'Kendall 44', 'Hailstorm', 'OSA', 'MacTav-45', 'TF-141', 'S-Ravage', 'M1', 'Hornet', 'Spartan SA3', 'P-LAW', 'Howitzer')
while True:
print("Open Supply Drop?.")
answer = input().lower()
if answer == "yes":
print("Weapons or Calling Card?")
answer1 = input().lower()
if answer1 == "Calling Card":
print("Please wait 3 seconds...")
time.sleep(3)
print(random.choice(callingcard))
elif answer1 == "Weapons":
print ("Please wait 3 seconds...")
time.sleep(3)
print(random.choice(weapons))
else:
print("Please wait 3 seconds...")
time.sleep(3)
break
else:
print("Please wait 3 seconds...")
time.sleep(3)
最佳答案
您将输入作为answer1 = input().lower
并将其更改为小写,因此它与任何条件都不匹配。将其更改为answer1 = input()
。
我已经编辑了您的代码,可以正常工作。
import time
import random
callingcard = ('BootsOnTheGround', 'TitanBaseCamp', 'TitanFacility',
'TitanicStorm', 'TitanicCanyon', 'TitanSandstorm', 'ToTheShip',
'AsteroidMines', 'TheSteelDragon', 'C6Assembly', 'C12Patrol')
weapons = ('Rack-9', 'Karma-45', 'NV-4', 'R3K', 'KBAR- 32', 'Trencher', 'Type-2', 'Volk', 'ERAD', 'FHR40', 'RPR Evo', 'KBS Longbow', 'DMR-1', 'Widowmaker', 'Banshee', 'DCM-8', 'Reaver', 'RAW', 'Mauler', 'Titan', 'EMC', 'Oni', 'Kendall 44', 'Hailstorm', 'OSA', 'MacTav-45', 'TF-141', 'S-Ravage', 'M1', 'Hornet', 'Spartan SA3', 'P-LAW', 'Howitzer')
while True:
print("Open Supply Drop?.")
answer = input().lower()
if answer == "yes":
print("Weapons or Calling Card?")
answer1 = input()
if answer1 == "Calling Card":
print("Please wait 3 seconds...")
time.sleep(3)
print(random.choice(callingcard))
elif answer1 == "Weapons":
print ("Please wait 3 seconds...")
time.sleep(3)
print(random.choice(weapons))
else:
print("Please wait 3 seconds...")
time.sleep(3)
break
else:
print("Please wait 3 seconds...")
time.sleep(3)
关于python - 这个简单的脚本不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44560272/