遇到的函数知识

列表的删除操作:

list.pop(索引)

del list[索引]

list.remove(值)

字典的删除操作:

dict.clear() 清空字典

dict.pop(键)

del dict(键)

zip()函数

zip() 函数用于将可迭代的对象作为参数,将对象中对应的元素打包成一个个元组,然后返回由这些元组组成的列表。 如果各个迭代器的元素个数不一致,则返回列表长度与最短的对象相同,

zip 方法在 Python 2 和 Python 3 中的不同:在 Python 3.x 中为了减少内存,zip() 返回的是一个对象。如需展示列表,需手动 list() 转换。

a = [1,2,3]
b = [4,5,6]
c = [4,5,6,7,8]
zipped=zip(a,b)
print(zipped)
print(list(zipped))
zipped2=zip(a,c)
print(list(zipped2))

<zip object at 0x0000013DD05DFB88>
[(1, 4), (2, 5), (3, 6)]
[(1, 4), (2, 5), (3, 6)]

bin()返回一个整数 int 或者长整数 long int 的二进制表示。
chr()用一个范围在 range(256)内的(就是0~255)整数作参数,返回一个对应的字符。
ord()返回字符串对应的 ASCII 数值

写出漂亮的博客就是为了以后看着更方便的。
原文地址:https://www.cnblogs.com/zhaowei5/p/10484532.html