"IndentationError: expected an indented block" in my python code
"IndentationError: expected an indented block" in my python code
好的,所以我尝试了 运行 我的代码(到目前为止),它有这个 annoying/weird 错误。我已经仔细检查过它,但它仍然是错误的。我知道这通常与缩进有关,但一切似乎都井井有条。我会把整个代码贴在那里。 PS 有些东西有主题标签,因此不活跃 - 它们是评论。
import time, sys
from os import system, name
from termcolor import colored
from random import randint
from time import sleep
Red = "3[0;31m"
Green = "3[0;32m"
Orange = "3[0;33m"
Blue = "3[0;34m"
Purple = "3[0;35m"
Cyan = "3[0;36m"
White = "3[0;37m"
rep = 0
money = 0
sleep1 = randint(1, 6)
def main():
ch = input("")
if ch == "1":
#1()
elif ch == "2":
#2()
elif ch == "3":
#3()
elif ch == "4":
#4()
elif ch == "5":
exit()
else:
setup_main()
def setup_main():
clear()
sleep(1)
print_slow(Green+"Reputation: "+str(rep))
print_slow(Green+"\nBritish Pounds: "+str(money))
print()
print_slow(White+"\nAbilities:")
print_slow(Orange+"\n[1] Let People On")
print_slow(Orange+"\n[2] Buy Items")
print_slow(Orange+"\n[3] Stamp Tickets")
print_slow(Orange+"\n[4] Sell Tickets")
print_slow(Orange+"\n[5] End Game")
main()
def print_slow(str):
for letter in str:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(0.05)
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def play_intro():
print_slow(colored("The Times:", 'red', attrs=['blink']))
print_slow(colored("\nThis is the week of bad luck! All the Train's Conductors have gone on strike! This is the week of need! The overground stations are looking for people that can mark tickets, and decide whether civilians are let in. Some terrorists have tried to sneak in countless times and no one has been able to stop them. If you join you will make a huge difference to our country!", 'red', attrs=['blink']))
print_slow(colored("\n ", 'red', attrs=['blink']))
input("\n>")
#For those forking this project, this is about making it different colours! =P
#text = colored("Hello, World!", 'red', attrs=['blink'])
def start():
print_slow(colored("Hello and Welcome to 'Ticket Master'!", 'cyan', attrs=['blink']))
print_slow(colored("\nHINT: Whenever you see the '>' symbol press Enter", 'cyan', attrs=['blink']))
input("\n>")
clear()
print_slow(colored("Ok good job!\n", 'cyan', attrs=['blink']))
print_slow(colored("Would you like to start the Introduction? (y/n)\n", 'cyan', attrs=['blink']))
Intro = input("")
if Intro == "y":
print_slow(colored("Ok, directing you to the intro...\n", 'cyan', attrs=['blink']))
sleep(sleep1)
clear()
play_intro()
else:
print()
clear()
print_slow("Enter a name:")
nad = input(Purple+"\nConductor ")
name = "Conductor "+nad
print_slow(White+"Nice to meet you "+Purple+name+White+"! It's time for you to start your new job!")
input("\n>")
sleep(2)
setup_main()
start()
将第 23 - 30 行中的注释替换为 pass
关键字(或仅在注释后添加)。 if 条件的主体不能为空。 pass
充当稍后要实现的代码的占位符。
像这样:
def main():
ch = input("")
if ch == "1":
#1()
pass
elif ch == "2":
#2()
pass
elif ch == "3":
#3()
pass
elif ch == "4":
#4()
pass
elif ch == "5":
exit()
else:
setup_main()
好的,所以我尝试了 运行 我的代码(到目前为止),它有这个 annoying/weird 错误。我已经仔细检查过它,但它仍然是错误的。我知道这通常与缩进有关,但一切似乎都井井有条。我会把整个代码贴在那里。 PS 有些东西有主题标签,因此不活跃 - 它们是评论。
import time, sys
from os import system, name
from termcolor import colored
from random import randint
from time import sleep
Red = "3[0;31m"
Green = "3[0;32m"
Orange = "3[0;33m"
Blue = "3[0;34m"
Purple = "3[0;35m"
Cyan = "3[0;36m"
White = "3[0;37m"
rep = 0
money = 0
sleep1 = randint(1, 6)
def main():
ch = input("")
if ch == "1":
#1()
elif ch == "2":
#2()
elif ch == "3":
#3()
elif ch == "4":
#4()
elif ch == "5":
exit()
else:
setup_main()
def setup_main():
clear()
sleep(1)
print_slow(Green+"Reputation: "+str(rep))
print_slow(Green+"\nBritish Pounds: "+str(money))
print()
print_slow(White+"\nAbilities:")
print_slow(Orange+"\n[1] Let People On")
print_slow(Orange+"\n[2] Buy Items")
print_slow(Orange+"\n[3] Stamp Tickets")
print_slow(Orange+"\n[4] Sell Tickets")
print_slow(Orange+"\n[5] End Game")
main()
def print_slow(str):
for letter in str:
sys.stdout.write(letter)
sys.stdout.flush()
time.sleep(0.05)
def clear():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def play_intro():
print_slow(colored("The Times:", 'red', attrs=['blink']))
print_slow(colored("\nThis is the week of bad luck! All the Train's Conductors have gone on strike! This is the week of need! The overground stations are looking for people that can mark tickets, and decide whether civilians are let in. Some terrorists have tried to sneak in countless times and no one has been able to stop them. If you join you will make a huge difference to our country!", 'red', attrs=['blink']))
print_slow(colored("\n ", 'red', attrs=['blink']))
input("\n>")
#For those forking this project, this is about making it different colours! =P
#text = colored("Hello, World!", 'red', attrs=['blink'])
def start():
print_slow(colored("Hello and Welcome to 'Ticket Master'!", 'cyan', attrs=['blink']))
print_slow(colored("\nHINT: Whenever you see the '>' symbol press Enter", 'cyan', attrs=['blink']))
input("\n>")
clear()
print_slow(colored("Ok good job!\n", 'cyan', attrs=['blink']))
print_slow(colored("Would you like to start the Introduction? (y/n)\n", 'cyan', attrs=['blink']))
Intro = input("")
if Intro == "y":
print_slow(colored("Ok, directing you to the intro...\n", 'cyan', attrs=['blink']))
sleep(sleep1)
clear()
play_intro()
else:
print()
clear()
print_slow("Enter a name:")
nad = input(Purple+"\nConductor ")
name = "Conductor "+nad
print_slow(White+"Nice to meet you "+Purple+name+White+"! It's time for you to start your new job!")
input("\n>")
sleep(2)
setup_main()
start()
将第 23 - 30 行中的注释替换为 pass
关键字(或仅在注释后添加)。 if 条件的主体不能为空。 pass
充当稍后要实现的代码的占位符。
像这样:
def main():
ch = input("")
if ch == "1":
#1()
pass
elif ch == "2":
#2()
pass
elif ch == "3":
#3()
pass
elif ch == "4":
#4()
pass
elif ch == "5":
exit()
else:
setup_main()