SyntaxError:无效语法(python)[关闭]

问题描述 投票:-4回答:1

我有一个无效的语法错误,但不明白为什么。任何建议,将不胜感激。这是代码:

def sum(arr):
  total = 0
  for x in arr:
    total += x
  return total


print sum([1, 2, 3, 4]) 

python quicksort divide
1个回答
0
投票

使用python3,您需要在打印件上加上括号。

print("something")

[print不带括号是较老的python2。

© www.soinside.com 2019 - 2024. All rights reserved.