Python02---整数,字符串,元组,列表,集合,字典

1.互相转化:dict(),可以将list()变dict

https://blog.csdn.net/hu827250322/article/details/91623800

eval(标准形式字符串)

https://www.cnblogs.com/wanglinjie/p/9221674.html

2.整数

1.整型和浮点型 除法的时候

2.各种进制

3.round(x,小数点位数) abs绝对值  divmod除余  pow幂余

4.math模块 celi向上取整  floor向下取整 modf返回整数部分小数部分 sqrt开根号

https://www.cnblogs.com/springsnow/p/11884745.html

3.字符串

1.转义r 字符串标志f

2.拼接+

3.重复*2

4.索引切片

5.成员运算

6.strip删除头尾,默认空格,可以指定

指定要去除的首尾字符,编译器会去除两端所有相应的字符,直到没有匹配的字符。

https://www.cnblogs.com/springsnow/p/11884745.html

https://www.runoob.com/python/att-string-strip.html

https://blog.csdn.net/lhy2239705435/article/details/90020157

7.split切割 指定num切分+1个字符串 rsplit右切割 换行切割splitline

8.join分割序列

9.替换replace旧新次数

10.find 是否包含,返回索引 index报错 count

11.填充zfill 更改填充center ljust rjust

https://www.cnblogs.com/springsnow/p/11884745.html

4.列表

1.切片

2.推导 表达式 变量 嵌套

3.删除元素,删除列表,连接,in

4.sort排序可翻转 insert(位置,“”) index(“”)count(“”)remove(“”)reverse(“”)extend(“”)clear()copy()

5.切片产生新的list

https://blog.csdn.net/weixin_42018112/article/details/88959052

https://www.cnblogs.com/ifantastic/p/3811145.html

5.元组同上

命名元组:特殊类

https://www.cnblogs.com/springsnow/p/11944380.html

6.集合

不重复,无序的

形式:如何定义

交并差:

add(“”)添加元素 update()可迭代对象,可以多个 remove("") discard("")不报错

7.字典

key唯一

构造方法:dict([()]) dict(a=1)

字典推导式:解压缩构造

方法:in只是key,get() pop()update(dict) fromkeys([],)都是一个值

统计次数

8.可变 只这三个list set dict

9.copy也是未来上面的可变,不影响就可以了

https://www.cnblogs.com/springsnow/p/12620248.html

10.推导式

https://www.cnblogs.com/sunBinary/p/10940965.html

11.序列

https://www.cnblogs.com/sunlong88/articles/9384925.html

posted @ 2020-09-13 16:55  Gaoyongxian666  阅读(170)  评论(0编辑  收藏  举报