摘要: 本文代码是从别处看到,觉得以后会有用,然后贴在这里,感谢作者 代码不是很复杂,就是对接口的一系列配置传参,实现自动翻译 import requests import time import random import hashlib import json class YouDao: def __i 阅读全文
posted @ 2021-12-06 14:54 小贝书屋 阅读(279) 评论(0) 推荐(0)
摘要: 如列表['a', 'b', 'a', 'c', 'a', 'a', 'b'],需要统计a、b、c出现次数(当然,例子里是数的出来的) 下方代码实现 from functools import reduce def frequencies(lst): f = {} for x in lst: f[x] 阅读全文
posted @ 2021-12-06 10:46 小贝书屋 阅读(94) 评论(0) 推荐(0)
摘要: 有时候需要打印出脚本总共执行耗费的时间,可以用下面的方法 直接上脚本 import time time_1 = time.time() def test(): print('1') print('2') for i in range(100): test() time_2 = time.time() 阅读全文
posted @ 2021-12-06 10:38 小贝书屋 阅读(440) 评论(0) 推荐(0)