Python:这种语法的工作原理是什么?为什么?{1,2,3,4}

Yug*_*dle 4 python syntax dictionary list set

据我们所知,

{} # Represents a dict
Run Code Online (Sandbox Code Playgroud)

{'one': 1} # Again a dict
Run Code Online (Sandbox Code Playgroud)

如何以及为什么这是一套:

{'one', 'two', 'three', 'four'} # I thought it should give syntax error
Run Code Online (Sandbox Code Playgroud)

但它给出了:

set(['one', 'two', 'three', 'four']) # Strange ?? [ Should this happen ? ]
Run Code Online (Sandbox Code Playgroud)

你能提供一些官方文件的链接吗?

Gar*_*tty 11

设置文字是一个3.x功能,已被反向移植到2.7.

这是一个有用的功能 - 请注意,也允许设置理解.