Python 3.x 列出使用*

Python 3.x 列出使用*,python-3.x,list,unpack,Python 3.x,List,Unpack,这是一种非常基本的语法,应该可以: # List Unpacking numbers = [12, 23, 31, 46, 75, 85, 63, 50, 65, 63, 43, 1, 4, 56, 7, 4] first, *others = numbers print(first) 但是我得到了这个错误, 文件“app.py”,第4行 首先,*其他=数字 ^ SyntaxError:无效语法 python是否删除了这个语法,或者我是否有什么做错了 检查自python 3.5以来引入的p

这是一种非常基本的语法,应该可以:

# List Unpacking

numbers = [12, 23, 31, 46, 75, 85, 63, 50, 65, 63, 43, 1, 4, 56, 7, 4]
first, *others = numbers
print(first)

但是我得到了这个错误, 文件“app.py”,第4行 首先,*其他=数字 ^ SyntaxError:无效语法


python是否删除了这个语法,或者我是否有什么做错了

检查自python 3.5以来引入的python版本


例如,我有Python3.7,你的代码运行得很好

你确定你正在Python3中运行thos代码吗?我的默认设置是为Python2之类的东西设置的。