Python Numpy Tutorials: 集合
来源:互联网 发布:观一叶而知秋 编辑:程序博客网 时间:2024/06/08 13:11
本文内容:
集合
# -*- coding: utf-8 -*-"""Python Version: 3.5Created on Mon May 8 16:46:14 2017E-mail: Eric2014_lv@sjtu.edu.cn@author: DidiLv"""# add(), len(), remove() function# Note: {**} stands for the setsanimals = {'cat', 'dog'}print('cat' in animals) # Check if an element is in a set; prints "True"print('fish' in animals) # prints "False"animals.add('fish') # Add an element to a setprint('fish' in animals) # Prints "True"print(len(animals)) # Number of elements in a set; prints "3"animals.add('cat') # Adding an element that is already in the set does nothingprint(len(animals)) # Prints "3"animals.remove('cat') # Remove an element from a setprint(len(animals)) # Prints "2"print("-------------------------")animals = {'cat', 'dog', 'fish'}# enumerate function using for iterationfor idx, animal in enumerate(animals): print('#%d: %s' % (idx + 1, animal))# Prints "#1: fish", "#2: dog", "#3: cat"# 集合解析set_1 = {animal for animal in enumerate(animals)}print(set_1)
0 0
- Python Numpy Tutorials: 集合
- Python Numpy Tutorials: 函数
- Python Numpy Tutorials: 类
- Python Numpy Tutorials: 数组
- Python Numpy Tutorials: 数据类型
- Python Numpy Tutorials: Broadcasting
- Python Numpy Tutorials: 元组
- Python Numpy Tutorials: 数组--1
- Python Numpy Tutorials: 数组--2
- Python Numpy Tutorials: 数组--3
- Python Numpy Tutorials: 数组--4
- Python Numpy Tutorials: 改变数组的维度
- Python Scipy&NUmpy Tutorials:Scipy与Matplot
- Python Numpy Tutorials: 数组乘法:点乘和矩阵(数组)乘法
- Python Numpy Tutorials: 数组中数学函数及变形(reshape)
- [warp portal] Python Tutorials
- Python Scipy Tutorials:Matplot
- Python中的Numpy的数组存取方法集合
- Jenkins执行shell脚本,提示“未找到命令”
- 系统通信RPC、httpclient
- CSUOJ 1922 Irony Ring 线段树 or 贪心
- Airflow学习笔记 --- job配置文件说明
- NSArray中containsObject的用法
- Python Numpy Tutorials: 集合
- 使用Android studio做一个简单的网站APP
- Serverless,后端小程序的未来
- 用 TensorFlow 做个聊天机器人
- spring-springmvc-mybatis(ssm)maven框架整合教程
- C++操作Redis数据库 如何安装hiredis
- 微信小程序开发不改工具初衷 致力线上线下场景营造
- 当多个手机同时连接电脑,adb 命令中如何进入指定设备
- fresco加载gif不能动