随笔分类 - Python使用技巧
摘要:代码: res = res.content #接口返回的内容 with open(path,mode='wb') as file: #excel的路径 file.write(res)
阅读全文
摘要:一般的全局变量只在当前文件生效,此模块为了跨文件来设置和获取全局变量: #用法: from extraUtils.globalArg import Global Global.setValue("ENV", "UAT") Global.getValue("ENV") class Global: _g
阅读全文
摘要:for i in range(3,10): #顾头不顾尾 print(i) #结果: 3 4 5 6 7 8 9
阅读全文
摘要:import random res=random.sample(range(low, high), n) #low指定最小 # high 指定最大 #n 指定获取多少个
阅读全文
摘要:with open('a.txt')as f1,open('b.txt')as f2: data1,data2 =f1.read(),f2.read() print(data1) print(data2)
阅读全文
摘要:方法一: list1 = ['k1','k2','k3'] list2 = ['v1','v2','v3'] dic = dict(map(lambda x,y:[x,y],list1,list2)) >>> print(dic) {'k3': 'v3', 'k2': 'v2', 'k1': 'v1
阅读全文