Python——Int&Bool
整数类型:
int类型,多用于数字运算
print(666)
print(6+1)
整数类型转换:
v1 = 666
v2 = str(v1)
#会得出字符串的666 v1 = True
v2 = int(v1)
#会得出整数1 v1 = False
v2 = int(v1)
#会得出整数0
布尔类型:
bool值用于判断使用。
print(False)
print(True)
布尔值的转换:
v1 = 6
v2 = bool(v1)
#任何非0数字转换为布尔值都会成为True v1 = "222"
v2 = bool(v1)
#任何非空字符串,转换为布尔值都会成为True
常用实例:
#——————————————列表中,数字和字符串转换再进行拼接——————————————
num = [11,22,33,44]
for i in range(0,len(num)):
num[i] = str(num[i])
result = '_'.join(num)
print(result)
#得出:11_22_33_44
Python——Int&Bool的更多相关文章
- Python的基础类型(int,bool,str):
Python的基础类型(int,bool,str): 1.int -------> 整形:主要用力进行数字计算 2.string ------>字符串:可以保存少量数据并进行相关的操作 3 ...
- int bool 字符串 列表 字典 集合
1.int和bool 输出i的最大二进制位数inti = 1000 print(i.bit_length()) 2. str int bool list set dict tuple 相互转换 pr ...
- 基本数据类型int,bool,str
.基本数据类型(int,bool,str) 基本数据数据类型: int 整数 str 字符串. 一般不存放大量的数据 bool 布尔值. 用来判断. True, False list 列表.用来存放大 ...
- 三.int , bool , str
03.万恶之源-基本数据类型(int, bool, str) 本节主要内容: 1. python基本数据类型回顾 2. int----数字类型3. bool---布尔类型4. str--- 字符串类 ...
- 第三天-基本数据类型 int bool str
# python基础数据类型 # 1. int 整数 # 2.str 字符串.不会用字符串保存大量的数据 # 3.bool 布尔值. True, False # 4.list 列表(重点) 存放大量的 ...
- 基本数据类型(int,bool,str)
目录: 1.int 数字类型 2.bool 布尔值 3.str 字符串类型 一.整型(int) 在python3中所有的整数都是int类型.但在python2中如果数据量 ...
- 基本数据类型(int,bool,str)
1.int bit_lenth() 计算整数在内存中占用的二进制码的长度 十进制 二进制 长度(bit_lenth()) 1 1 1 2 10 2 4 100 3 8 1000 4 16 10000 ...
- python-基本数据类型(int,bool,str)
一.python基本数据类型 1. int ==> 整数. 主要⽤用来进⾏行行数学运算 2. str ==> 字符串串, 可以保存少量量数据并进⾏行行相应的操作 3. bool==> ...
- day3------基本数据类型int, bool, str,list,tuple,dict
基本数据类型(int, bool, str,list,tuple,dict) 一.python基本数据类型 1. int 整数. 主要用来进行数学运算 2. str 字符串, 可以保存少量数据并进 ...
随机推荐
- javascript数组遍历的几种常用方法性能分析对比
前言: 数组遍历有很多种方法,虽然不同方法有不同的特性及适用环境,除了普通飞for循环之外,for...in能直接输出数组元素的索引,for...of能直接输出数组元素的值,map则可以直接生成新的数 ...
- MSYS2 更新源
博客转载自:https://blog.csdn.net/puputaoexin/article/details/81780492 在使用msys2下载文件的时候回出现下载速度奇慢,且经常因为各种原因报 ...
- redis连接池——JedisPool和JedisCluster的介绍与使用
目录 Jedis使用方式的介绍 Redis连接池介绍 创建连接池配置文件 单机版的Redis连接池 集群版的Redis连接池 总结 Jedis使用方式的介绍 Jedis就是Java实现的操作Redis ...
- 流行-Manifold学习理解与应用
流行-Manifold[1] 流形,也就是 Manifold . 1. 比较好的形象理解 流形学习的观点是认为,我们所能观察到的数据实际上是由一个低维流形映射到高维空间上的,即这些数据所在的空间是“ ...
- [LeetCode] 139. Word Break 单词拆分
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine ...
- [LeetCode] 773. Sliding Puzzle 滑动拼图
On a 2x3 board, there are 5 tiles represented by the integers 1 through 5, and an empty square repre ...
- ou can mix require and export. You can't mix import and module.exports.
ou can mix require and export. You can't mix import and module.exports.
- [转帖]IOC Security: Indicators of Attack vs. Indicators of Compromise
IOC Security: Indicators of Attack vs. Indicators of Compromise https://www.crowdstrike.com/blog/ind ...
- IDEA的一个设置, 关系到maven的运行, 默认是使用jre的, 有时候不够用需要改成jdk
- MapReduce面试题
什么是mapreduce Mapreduce是一个分布式运算程序的编程框架,是用户开发“基于hadoop的数据分析应用”的核心框架.容错高,扩展好,适合pB数据处理 MapReduce 执行过程分析 ...