Python 3中解析时发生意外的EOF?

时间:2018-08-13 18:43:02

标签: python python-3.x

每次使用.format()运行此代码时,都会收到此错误

代码:

list_A = [1,2,3,4] #Declaring List_A with items 1,2,3,4
list_B = [6,7,8,9] #Declaring List_B with items 5,6,7,8
print("list_A is: {} and list_B is: {}".format(list_A, list_B)) #Prints list_A and list_B
print("length of list_A is: {0} and length of list_B is: {1}".format(len(list_A), len(list_B)) #Prints length of list_A with list_B

输出

File "<ipython-input-76-d54f829c5c52>", line 5
print("length of list_A is: {0} and length of list_B is: {1}".format(len(list_A), len(list_B)) #Prints length of list_A with len()
^
SyntaxError: unexpected EOF while parsing

1 个答案:

答案 0 :(得分:0)

您缺少结束语。

print("length of list_A is: {0} and length of list_B is: {1}".format(len(list_A), len(list_B))) #Prints length of list_A with list_B