简体   繁体   English

是否可以用花括号创建冻结集?

[英]Is it possible to create frozen sets with curly braces?

It appears that one can only create a frozenset using the frozenset() constructor.似乎只能使用frozenset()构造函数创建一个frozenset

Is this true or is there a textual way to create a frozen set?这是真的还是有文本方式来创建冻结集? I can find no evidence one way or the other in the docs .在文档中找不到任何证据。

One sentence above what you linked is the answer (emphasis mine):你链接上面的一句话就是答案(强调我的):

Non-empty sets ( not frozensets ) can be created by placing a comma-separated list of elements within braces, for example: {'jack', 'sjoerd'} , in addition to the set constructor.非空集(不是 frozensets )可以通过在大括号内放置一个逗号分隔的元素列表来创建,例如: {'jack', 'sjoerd'}除了set构造函数。

So in short, no, there is no way to do that所以简而言之,不,没有办法做到这一点

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM