首页 > 教育

foriinclass:运行结果invalidsyntax怎么解决

更新时间2019-08-04 07:35:16

import easygui

class Car():

def __init__(self,name,speed):

cars=[Car('宝马','100km/h'),

  Car('奔驰','200km/h'),

  Car('法拉利','300km/h')

for i in cars:

easygui.msgbox(i.speed)


运行结果出现invalid syntax怎么解决?

你对python最基本的没有了解,它是以空格要区别语句的,你的一行上只能有一个语句且必须完整,你程序,不但把一行分成多行且不完整(少中括号了),且缩进也完全不对

正确的语法为

for i in class: 运行结果invalid syntax怎么解决


上一篇:当月事假超过3天,取消当月休息,什么意思

下一篇:shesaidtheprogramwasdesignedforsomeofthebrighterteenagerstoexperienceadifferentcu