# 剩余 内置函数
# 数据类型:int bool……
# 数据结构:dict list tuple set str
# l = [1,2,3,4,5]
# l.reverse()
# print(l) #反转 [5, 4, 3, 2, 1]
#
# l2 = [1,2,3,4,5]
# ret = reversed(l2)
# print(ret) # 不改变原来的列表,返回一个反向的迭代器
#
# l = (1,2,34,213,5612,342,43)
# sli = slice(1,5,2)
# print(l[sli]) # (2, 213)
# print(format('test','<20')) # 左对齐
# print(format('test','>20')) # 右对齐
# print(format('test','^20'))# 居中显示
# bytes 转换成bytes类型
# print(bytes('你好',encoding='GBK')) # b'\xc4\xe3\xba\xc3' Unicode转换成GBK
# print(bytes('你好',encoding='utf-8')) # b'\xe4\xbd\xa0\xe5\xa5\xbd' Unicode转换成UTF-8
# print(bytes('你好',encoding='GBK').decode('GBK')) # 你好
# print(bytes('你好',encoding='utf-8').decode('UTF-8')) # 你好
# gbk转换成utf-8
# 先将GBK转换成unicode,再将Unicode转换成UTF-8
# 网络编程 只能转二进制
# 文件存储
# 照片和视频 也是以二进制存储
# html网页爬取到的也是编码
# bytearray修改字符串的时候,可以转换成byte的方式,可以节省内存
# b_array= bytearray('你好',encoding='UTF-8')
# print(b_array) # bytearray(b'\xe4\xbd\xa0\xe5\xa5\xbd')
# print(b_array[0]) # 228
# 切片:字节类型 不占内存
# 字节:换成字符串,占据内存
# print(memoryview(bytes('你好',encoding='UTF-8'))) #
# 字符按照Unicode转数字
# print(ord('a')) # 97
# # 数字按照Unicode转字符
# print(chr(97)) # a
# # 只要是ascii中的内容,就打印出来,不是就转成\u
# print(ascii('好')) # '\u597d'
# print(ascii('123')) # '123'
# # repr带着字符类型打印
# name = 'fangfang'
# print('你好%s'%name) # 你好fangfang
# print('你好%r'%name) # 你好'fangfang'
#
# print(repr('1')) # '1'
# print(repr(1)) # 1
# # ALL:可迭代内容里面有任意一个值是0,则整个为0
# print(all(['a','','123'])) # False
# print(all(['a','123'])) # True
# print(all([0,'123'])) # False
#
# # Any:可迭代内容里面所有值是0,则整个为0
# print(any(['','',0])) # False
# print(any(['a','123'])) # True
# print(any([0,'123'])) # True
# # zip
# l = [1,2,3]
# l2 = ['a','b','c','d']
# l3 = ('*','**',[1,2,3])
# l4 = {'k1':'v1','k2':'v2'}
# print(zip(l,l2)) # 是一个迭代器
# for i in zip(l,l2,l3,l4):
# print(i)\
# (1, 'a', '*', 'k1')
# (2, 'b', '**', 'k2')
# filter
# def is_odd(x):
# return x%2 == 1
# def is_str(s): # 过滤字符串
# return type(s) == str
# def is_delete_empty(s): # 过滤空数据
# return str(s) and str(s).strip()
# ret = filter(is_delete_empty,[1,2,'hello',23,None,'world',7,' ',[],'hehe'])
# for i in ret:
# print(i) # 1 3 23 7
# print([i for i in [1,2,3,23,6,7] if i%2 == 1 ]) # [1, 3, 23, 7]
#
# from math import sqrt
# def function(x):
# return sqrt(x)%1 == 0
# ret = filter(function,range(1,101))
# print(ret) #
# for i in ret:
# print(i)
# MAP
# ret = map(abs,[1,-4,6,-8]) #
# print(ret) #