Python之set方法
class set(object):
"""
set() -> new empty set object
set(iterable) -> new set object
"""
def add(self, *args, **kwargs): # 添加元素
"""
Add an element to a set,
This has no effect if the element is already present.
"""
def clear(self, *args, **kwargs): # 清除内容
""" Remove all elements from this set. """
def copy(self, *args, **kwargs): # 浅拷贝,只复制地址空间第一层。
""" Return a shallow copy of a set. """
def difference(self, *args, **kwargs): # A中存在,B中不存在,并将其赋值给新值。
"""
Return the difference of two or more sets as a new set.
"""
def difference_update(self, *args, **kwargs): # 从当前集合中删除和B中相同的元素,并更新自己。
""" Remove all elements of another set from this set."""
def discard(self, *args, **kwargs): # 移除指定元素,不存在不会报错。
"""
Remove an element from a set if it is a member.
If the element is not a member, do nothing.
"""
def intersection(self, *args, **kwargs): #取交集
"""
Return the intersection of two sets as a new set.
(i.e. all elements that are in both sets.)
"""
def intersection_update(self, *args, **kwargs): # 取交集并更新到A。
""" Update a set with the intersection of itself and another. """
def isdisjoint(self, *args, **kwargs): # real signature unknown
""" Return True if two sets have a null intersection. 如果没有交集,返回True,否则返回False"""
def issubset(self, *args, **kwargs): # A是否是B子序列
""" Report whether another set contains this set."""
def issuperset(self, *args, **kwargs): # A是否是B父序列
""" Report whether this set contains another set."""
def pop(self, *args, **kwargs): # 移除元素
"""
Remove and return an arbitrary set element.
Raises KeyError if the set is empty.
"""
def remove(self, *args, **kwargs): # 移除指定元素,不存在会报错。
"""
Remove an element from a set; it must be a member.
If the element is not a member, raise a KeyError.
"""
def symmetric_difference(self, *args, **kwargs): # 对称差集
"""
Return the symmetric difference of two sets as a new set.
(i.e. all elements that are in exactly one of the sets.)
"""
def symmetric_difference_update(self, *args, **kwargs): # 对称差集,并更新到A中
""" Update a set with the symmetric difference of itself and another."""
def union(self, *args, **kwargs): # 并集
"""
Return the union of sets as a new set.
(i.e. all elements that are in either set.)
"""
def update(self, *args, **kwargs): # 更新元素
""" Update a set with the union of itself and others."""
Python之set方法的更多相关文章
- Python测试函数的方法之一
Python测试函数的方法之一 首先介绍简单的try......except尝试运行的放例如下面的图和代码来简单介绍下: 注释:提醒以下代码环境为2.7.x 请3.x以上的同学们老规矩print(把打 ...
- 使用python原生的方法实现发送email
使用python原生的方法实现发送email import smtplib from email.mime.text import MIMEText from email.mime.multipart ...
- Python中sorted()方法
Python中sorted()方法的用法 1.先说一下iterable,中文意思是迭代器. Python的帮助文档中对iterable的解释是:iteralbe指的是能够一次返回它的一个成员的对象.i ...
- python类及其方法
python类及其方法 一.介绍 在 Python 中,面向对象编程主要有两个主题,就是类和类实例类与实例:类与实例相互关联着:类是对象的定义,而实例是"真正的实物",它存放了类中 ...
- Python内置方法的时间复杂度(转)
原文:http://www.orangecube.net/python-time-complexity 本文翻译自Python Wiki本文基于GPL v2协议,转载请保留此协议. 本页面涵盖了Pyt ...
- Python LOGGING使用方法
Python LOGGING使用方法 1. 简介 使用场景 场景 适合使用的方法 在终端输出程序或脚本的使用方法 print 报告一个事件的发生(例如状态的修改) logging.info()或log ...
- [Python]读写文件方法
http://www.cnblogs.com/lovebread/archive/2009/12/24/1631108.html [Python]读写文件方法 http://www.cnblogs.c ...
- 转最简便安装python+selenium-webdriver环境方法
最简便安装python+selenium-webdriver环境方法 from:http://www.easonhan.info/python/2013/12/07/active-python-ins ...
- python字符串replace()方法
python字符串replace()方法 >>> help(str.replace)Help on method_descriptor:replace(...) S.repla ...
- Python中__init__方法介绍
本文介绍Python中__init__方法的意义. __init__方法在类的一个对象被建立时,马上运行.这个方法可以用来对你的对象做一些你希望的 初始化 .注意,这个名称的开始和结尾 ...
随机推荐
- Ubuntu 18.04 LTS 常用软件安装杂记
之前个人笔记本装的是 Linux Mint,用了一段时间但是体验不佳,所以打算换成 Ubuntu .作为一个 Linux 小白,当时配置一些软件环境费了不少时间.这次打算简单记录下,和大家分享一下我的 ...
- django 开发笔记1
1.布置到云服务器 使用 python3 manage.py runserver提示错误,需要将settings.py 中 ALLOWED_HOSTS 字典中加入 localhost;0.0.0.0; ...
- 使用Selenium模块报错的解决办法 (FileNotFound,WebDriverException)
添加Chrome浏览器程序的目录到系统Path变量中: C:\Users\%USERNAME%\AppData\Local\Google\Chrome\Application ,使用pip3 inst ...
- 实验八 <FBG> 基于原型的团队项目需求调研与分析
<FBG>团队项目原型设计:http://www.cnblogs.com/ymm3/p/9012534.html GitHub的链接地址:https://github.com/FBGfbg ...
- 学习笔记77—Iphone集
****************************************************** 如有谬误,请联系指正.转载请注明出处. 联系方式: e-mail: heyi9069@gm ...
- [python]html格式转md格式
html格式转md格式 # 模块html2text pip install html2text/pip3 install html2text 测试: import html2text as ht te ...
- 《SQL 基础教程》第六章:函数、谓词、CASE 表达式
函数是 SQL 中的一部分.在 SQL 中,除了普通的函数之外,还有特殊的函数(谓词和 CASE 表达式)用于各种情况. 函数 函数的种类有: 算术函数 字符串函数 日期函数 转换函数(用于转换数据类 ...
- C语言实验一(3)
#include<stdio.h> #include<math.h> int main() { float x,y; scanf("%f,%f",& ...
- BaseDao封装
1.lombok 1) 在pom.xml中导入依赖 <!--导入lombok--> <!-- https://mvnrepository.com/artifact/org.proje ...
- Redis 知识整理
1. 什么是Redis Redis是开源的.基于内存的键值对数据库. 2. Redis 的基本操作 set key value => mset, setbit, hset get key =&g ...