Python 代码中的错误是什么:在时间方法中获取无效语法
在这段代码中,当编译器使用此语句时Python 代码中的错误是什么:在时间方法中获取无效语法,python,python-3.x,delay,python-3.6,timedelay,Python,Python 3.x,Delay,Python 3.6,Timedelay,在这段代码中,当编译器使用此语句时 #multiplication table with time delay import time num=int(input("Enter the value for which you want the multiplication table for:")) print("The table will be as:\n") for i in range(1,11): { print(num,"x",i,"=",num*i,"\
#multiplication table with time delay
import time
num=int(input("Enter the value for which you want the multiplication table for:"))
print("The table will be as:\n")
for i in range(1,11):
{
print(num,"x",i,"=",num*i,"\n")
time.sleep(3)
}
print("The table is completed")
input("Press enter to exit")
它显示无效的语法错误。这段代码有什么错误?它在抱怨{}s。在Python中,它们不定义块,而是定义字典。因此,{}中的内容应该是字典文本,但这不是您所拥有的。您可能想要:
time.sleep(3)
注意,缩进定义块
for i in range(1, 11):
print(num, "x", i, "=", num * i, "\n")
time.sleep(3)