'''
l.sort() sort不带参数, 升序排序
reverse 布尔类型: true:降序排序, false: 升序排序, 默认值是false
key 比较函数, 默认是按照数据类型比较(整数,默认int)
'''
l = [10, 0, 1, 6, 12, 8]
l.sort(key=str)
print(l)
t = (10, 0, 1, 6, 12, 8)
nt = sorted(t, reverse=True, key=str)
print(nt)
print(t)
'''
sort是列表的方法, sorted是全局方法
sort会改变原有对象的数据, sorted不会改变原有数据而是返回一个新对象
sort只能排序列表, sorted可以排序列表/元组
sorted返回的数据类型是列表
reverse 布尔类型: true:降序排序, false: 升序排序, 默认值是false
key 比较函数, 默认是按照数据类型比较(整数,默认int)
'''
'''
10 0
int: 10 0
str: str(10),str(0),str(1),str(6),str(12),str(8) ==> ['10', '0', '1', '6', '12', '8'] 排序后: ['0','10']
'1a' '12'
'''
'''
ASCII表
参考地址: https://baike.baidu.com/item/ASCII/309296?fromtitle=ascii%E7%A0%81%E8%A1%A8&fromid=19660475&fr=aladdin
主要掌握知识点:
1. 0 a A 在ASCII中的编码
2. ASCII使用16进制的表示形式: 如\x01
'''
'''
集合的元素 只能是不可变类型, 不能是可变类型
字典的键 只能是不可变类型, 不能是可变类型
改变指的是内存中数据的改变
a-> 0x001(内存空间)
不可变类型: int/float/str/tuple/bool
可变类型: list/set/dict
'''
'''
map(映射) 将一个元素通过一种方法转换成另外一个元素
- 转换函数
- 待映射的数据
会对列表里的每个元素, 使用转换函数进行转换, 得到一个新的列表
map(str,(0,1,2))
map函数的返回值是map对象, 而非列表/元组...
函数/方法
书名1 作者名1
书名2 作者2
'''
map(str, [0, 1, 2])
'''
交叉并集:
交集: & -> and(且): a and b 即是且是, 例如: s1 & s2
并集: | -> or(或) a or b , 例如: s1 | s2
差集: - , 例如: s1-s2
集合方法:
交集: intersection, 例如: s1.intersection(s2) 等价于 s1 & s2
并集: union, 例如: s1.union(s2), s1 | s2
差集: difference, 例如: s1.difference(s2) , s1-s2
'''
r'C:\Program Files\Google\Chrome\Application\xxx\xxx'
r->raw原始字符
No Leanote account? Sign up now.