Python 为什么我会得到这个SyntaxError?

Python 为什么我会得到这个SyntaxError?,python,syntax-error,Python,Syntax Error,我是python新手,我遇到了这个错误,无法摆脱它。我读过文档和教程,但我看不出问题出在哪里。以下是错误: Caused by: SyntaxError: ("no viable alternative at input 'if'" , ('<iostream>', 107, 14, ' if b.getType() != Material.WATER:\n')) 原因:SyntaxError:(“输入'if',(''''107,14',if b.getT

我是python新手,我遇到了这个错误,无法摆脱它。我读过文档和教程,但我看不出问题出在哪里。以下是错误:

Caused by: SyntaxError: ("no viable alternative at input 'if'" , ('<iostream>', 107, 14, '              if b.getType() != Material.WATER:\n'))
原因:SyntaxError:(“输入'if',(''''107,14',if b.getType()!=Material.WATER:\n')没有可行的替代方案)
这是我的密码:

    removable = True
    ticker_vertical = 0.0
    ticker_horisontal = (random.random() * 2 * math.pi)
    l = sender.getLocation()
    b = l.getBlock()
    entity = l.getWorld().spawnFallingBlock(l, b.getType(), b.getData())
    if args[0] == "spawn":
       if l.getBlock().getType() != Material.AIR:
          entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
          if b.getType() != Material.WATER: #this is line which is causing error
             b.setType(Material.AIR)
          else:
              pass
       else:
           pass
       l = sender.getLocation()
       radius = math.sin(ticker_vertical * 2)
       v = Vector(radius * math.cos(horisontal), 0.5, radius * math.sin(horisontal))
       b1 = entity.getLocation().add(v.clone().normalize()).getBlock()
       if b1.getType() != Material.AIR:
          new_blocks.add(b.getLocation(), b.getType(), b.getData())
       entities = entity.getNearbyEntities(1.0, 1.0, 1.0)
       for e in entities:
           if e.hasMetaData("vortex"):
             new_blocks.add(entity)
       entity.setVelocity(v)
       if ticker_vertical < 1.0:
          ticker_vertical += 0,05
    elif args[0] == "stop":
        entity.remove()
removable=True
股票代码垂直=0.0
ticker_horisontal=(random.random()*2*math.pi)
l=发送方。getLocation()
b=l.getBlock()
entity=l.getWorld().spawnFallingBlock(l,b.getType(),b.getData())
如果args[0]=“繁殖”:
如果l.getBlock().getType()!=材料.空气:
setMetadata(“漩涡”,FixedMetadataValue(PyPlugin,“受保护”)
如果b.getType()!=Material.WATER:#这是导致错误的行
b、 设置类型(材料、空气)
其他:
通过
其他:
通过
l=发送方。getLocation()
半径=数学sin(股票代码垂直*2)
v=向量(半径*数学坐标系(水平),0.5,半径*数学坐标系(水平))
b1=entity.getLocation().add(v.clone().normalize()).getBlock()
如果b1.getType()!=Material.AIR:
新建块。添加(b.getLocation()、b.getType()、b.getData())
entities=entity.getNearbyEntities(1.0、1.0、1.0)
对于电子商务实体:
如果e.hasMetaData(“漩涡”):
新建块。添加(实体)
实体。设定速度(v)
如果ticker_垂直<1.0:
股票行情垂直+=0,05
elif参数[0]=“停止”:
entity.remove()

提前感谢!

请看前一行;您缺少一个
右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
#                                              ^--- closes there ----^
#                 ^ --- open                           but no close --^
再往下看,您使用了逗号而不是小数点:

if ticker_vertical < 1.0:
    ticker_vertical += 0,05

行,它们不做任何事情,也不需要;您缺少一个
右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
#                                              ^--- closes there ----^
#                 ^ --- open                           but no close --^
再往下看,您使用了逗号而不是小数点:

if ticker_vertical < 1.0:
    ticker_vertical += 0,05

行,它们不做任何事情,也不需要;您缺少一个
右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
#                                              ^--- closes there ----^
#                 ^ --- open                           but no close --^
再往下看,您使用了逗号而不是小数点:

if ticker_vertical < 1.0:
    ticker_vertical += 0,05

行,它们不做任何事情,也不需要;您缺少一个
右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
#                                              ^--- closes there ----^
#                 ^ --- open                           but no close --^
再往下看,您使用了逗号而不是小数点:

if ticker_vertical < 1.0:
    ticker_vertical += 0,05

行,它们不起任何作用,也不需要。

第9行缺少一个右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
应该是:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected"))

第9行缺少一个右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
应该是:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected"))

第9行缺少一个右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
应该是:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected"))

第9行缺少一个右括号:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected")
应该是:

entity.setMetadata("vortex", FixedMetadataValue(PyPlugin, "protected"))

而且
ticker\u vertical+=0,05
看起来也不正确
创建一个
元组
ticker\u vertical+=0,05
看起来也不正确
创建一个
元组
ticker\u vertical+=0,05
看起来也不正确
创建一个
元组
ticker\u vertical+=0,05
看起来也不正确
创建一个
元组
。噢,非常感谢。我知道这是我看不见的蠢事。关于逗号,这只是输入错误:D非常感谢!:)我会尽快(5分钟)接受你的回答。哦,非常感谢。我知道这是我看不见的蠢事。关于逗号,这只是输入错误:D非常感谢!:)我会尽快(5分钟)接受你的回答。哦,非常感谢。我知道这是我看不见的蠢事。关于逗号,这只是输入错误:D非常感谢!:)我会尽快(5分钟)接受你的回答。哦,非常感谢。我知道这是我看不见的蠢事。关于逗号,这只是输入错误:D非常感谢!:)我会尽快(5分钟)接受你的回答。