class student(object):
def __init__(self, name, id):
self.name = name
self.id = id
def __repr__(self):
return str(self.id) + str(self.name)
a = student("qqqq", 20102848)
hash(a) # 哈希值
> 8779136423273
id(a) # 内存地址
> 139708044649616
ascii(a) # 获得真实返回值
> '20102848qqqq'
a = map(lambda x: str(x), [1,2,23,3,1,45])
print(list(a))
> ['1', '2', '23', '3', '1', '45']
- slice()
slice()函数是按照index进行切片
a = ["hello", "world", "hello", "CSDN", "slice"]
b = a[slice(0, 5, 2)]
print(b)
> ['hello', 'hello', 'slice']
a = [1,2,3,4,5]
b = ["hello", "world", "hello", "CSDN", "slice"]
d = dict(zip(a,b))
print(d)
> {1: 'hello', 2: 'world', 3: 'hello', 4: 'CSDN', 5: 'slice'}