[TOC]
lstrip()和rstrip()
1 | str.lstrip([chars]) # 删除字符串左边的空格或指定字符 |
字典中找最值
1 | dogdistance = {'dog-dog': 33, 'dog-cat': 36, 'dog-car': 41, 'dog-bird': 42} |
列表中找最值
1 | c = [-10,-5,0,5,3,10,15,-20,25] |
字典按照value排序
返回list:1
sorted(d.items(),key = lambda x:x[1],reverse = True)
1 | import operator |
返回只有键的tuple1
sorted(d,key=d.__getitem__)
numpy array 找最值
1 | a = np.arange(9).reshape((3,3)) |
1 | print(np.where(a==np.max(a))) |
List做除法
1 | list(map(lambda x: x//4, list_a)) |