Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 代码中的错误是什么:在时间方法中获取无效语法_Python_Python 3.x_Delay_Python 3.6_Timedelay - Fatal编程技术网

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)