最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

怎么加两套?

SEO心得admin33浏览0评论
本文介绍了怎么加两套?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 a = {'a', 'b', 'c'} b = {'d', 'e', 'f'}

我想添加以上两个设定值.我需要像

I want to add above two set values. I need output like

c = {'a', 'b', 'c', 'd', 'e', 'f'}

推荐答案

你所要做的就是把它们结合起来

All you have to do to combine them is

c = a | b

集合是唯一值的无序序列.a |b 或 a.union(b) 是两个集合的并集(一个新集合,其中包含在任一集合中找到的所有值).这是一类称为设置操作"的操作,Python sets 为提供方便的工具.

Sets are unordered sequences of unique values. a | b or a.union(b) is the union of the two sets (a new set with all values found in either set). This is a class of operation called a "set operation", which Python sets provide convenient tools for.

发布评论

评论列表(0)

  1. 暂无评论