摘要: 一、json json就是一个字符串,只不过是所有语言能解析这个字符串。1.1 把python的数据类型转为json import json d = {'name': 'xiaohei', 'cars': [1, 2, 3], 'house': (4, 5, 6), 'addr': '北京'} # 阅读全文
posted @ 2021-01-17 21:23 橄榄叶 阅读(227) 评论(0) 推荐(0)
摘要: import random import string # 随机整数: print random.randint(1,50) # 随机选取0到100间的偶数: print random.randrange(0, 101, 2) # 随机浮点数: print random.random() print 阅读全文
posted @ 2021-01-02 14:21 橄榄叶 阅读(494) 评论(0) 推荐(0)
摘要: file1=open("test.txt","r",encoding="utf-8")file2=open("test1.txt","w",encoding="utf-8")txt=file1.read()file2.write(txt) 1 转换a,b的值 a=1 b=2 a,b=b,a 2 if 阅读全文
posted @ 2021-01-02 10:57 橄榄叶 阅读(95) 评论(0) 推荐(0)
摘要: 1 文件读 fo=open("foo.txt","r+") fo.readline(10) / 读多少个字符 str=fo.readlines() /文件中的所有新息读出,放到缓存中 print(str) 打印出lisT fo.read() --读出所有的文件 # with open ,python 阅读全文
posted @ 2020-12-27 16:12 橄榄叶 阅读(212) 评论(0) 推荐(0)
摘要: 1. 列表操作 1.1 列表 list = [1,2,3,'James','Paul'] list = [i for i in range(10)] 列表的拆分 names=['1','2','3']a,b,c=namesprint(a,b,c) 1.2 列表创建,深浅拷贝 li = [1,3,2, 阅读全文
posted @ 2020-12-27 10:28 橄榄叶 阅读(355) 评论(0) 推荐(0)
摘要: 1. 去掉空格和特殊符号 name=’ abcdkjdfjkdjfidfdd’ name.strip() 去掉空格和换行符 name.strip('xx') 去掉某个字符串 name.lstrip() 去掉左边的空格和换行符 name.rstrip() 去掉右边的空格和换行符 2. 字符串的搜索和替 阅读全文
posted @ 2020-12-27 09:37 橄榄叶 阅读(410) 评论(0) 推荐(0)
摘要: 1. 传参 { "error_code": 0, "login_info": { "login_time": "20201215213303", "sign": "b440add44d39d0a9089308de121bcae1", "userId": 47749 } } POSTMAN的传参设置 阅读全文
posted @ 2020-12-16 20:43 橄榄叶 阅读(96) 评论(0) 推荐(0)