05 2021 档案

摘要:1 def add(a,b): 2 return a+b 3 4 d = {"a":1,"b":2} # 两个**代表传的是字典 5 L= [1,2,3] # 一个*代表传的是list 6 print(add(**d)) 7 print(*L) 阅读全文
posted @ 2021-05-25 17:23 等待iing 阅读(54) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2021-05-25 17:17 等待iing 阅读(6) 评论(0) 推荐(0)
摘要:1 import pymysql 2 ip = 'XX,XX,XX,XX' 3 user = 'XXX' 4 password = 'XXX' #密码必须是字符串 5 db = 'XXX' 6 port = 3306 #端口号必须写int类型 7 8 connect = pymysql.connec 阅读全文
posted @ 2021-05-25 17:16 等待iing 阅读(60) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2021-05-25 17:14 等待iing 阅读(7) 评论(0) 推荐(0)
摘要:1 import faker 2 # 可用于造数据 方便 3 #如果要生成中文的随机数据,我们可以在实例化时给locale参数传入‘zh_CN’ 4 f = faker.Faker(locale="zh_CN") #随机 5 print(dir(f)) #列出当前函数有哪些方法 6 7 print( 阅读全文
posted @ 2021-05-25 17:13 等待iing 阅读(49) 评论(0) 推荐(0)
摘要:1 import faker,xpinyin 2 # f = faker.Faker(locale='zh-CN') 3 # for i in range(100): 4 # print(f.name()) 5 6 # b = "胡月梅" 7 # c = xpinyin.Pinyin() 8 # d 阅读全文
posted @ 2021-05-25 17:12 等待iing 阅读(160) 评论(0) 推荐(0)
摘要:1 import random 2 3 print(random.randint(100000,99999)) #随机整数 4 5 print(random.uniform(1,99)) #随机小数 6 7 a = '1234566' 8 9 L = [2.23.24.23.545.4151] 10 阅读全文
posted @ 2021-05-21 11:09 等待iing 阅读(37) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2021-05-21 11:05 等待iing 阅读(7) 评论(0) 推荐(0)
摘要:1 import os 2 3 os.rename('m1.py','M1.py') #重命名 4 5 os.remove('M1.py') #删除文件,不能删除文件夹 6 7 os.rmdir('test') #删除空文件夹 8 9 10 11 os.mkdir("TEST") #创建文件夹 父目 阅读全文
posted @ 2021-05-21 10:45 等待iing 阅读(76) 评论(0) 推荐(0)
摘要:1 常用: 2 3 type() 4 5 int() 6 7 float() 8 9 list() 10 11 str() 12 13 tuple() 14 15 set() 16 17 dict() 18 19 20 21 sum() #计算总和 22 23 L = [1,2,3,5,23,235 阅读全文
posted @ 2021-05-21 09:51 等待iing 阅读(69) 评论(0) 推荐(0)
摘要:1 解包 2 msg = 'admin,123456' 3 # msg1 = {} 4 # username = msg.split(',')[0] 5 # password = msg.split(',')[1] 6 username,password = msg.split(",") #只针对l 阅读全文
posted @ 2021-05-13 17:59 等待iing 阅读(62) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2021-05-13 17:54 等待iing 阅读(11) 评论(0) 推荐(0)
摘要:1 文件修改 2 # f = open("user.txt",encoding="utf-8") 3 # a = f.read() 4 # b = a.replace("nihaosadf","你好") 5 # # print(b) 6 # f.close() 7 # 8 # f = open("u 阅读全文
posted @ 2021-05-13 17:53 等待iing 阅读(91) 评论(0) 推荐(0)
摘要:1 全局变量 2 # a = 100#全局变量 少用全局变量 会一直占内存 3 # def test(): 4 # global a 5 # a=1 6 # print(a) 7 8 # test() 9 # print(a) 10 """ 11 def test(): 12 global a 13 阅读全文
posted @ 2021-05-13 17:48 等待iing 阅读(80) 评论(0) 推荐(0)
摘要:1 import json 2 # python的数据类型转成json 3 # 字典转字符串 4 d = {"code":0,"msg":"操作成功","token":"XXXX"} 5 # print(d) 6 # json_str = json.dump(d,ensure_ascii=False 阅读全文
posted @ 2021-05-13 17:45 等待iing 阅读(63) 评论(0) 推荐(0)
摘要:1 拷贝 2 import copy 3 L = [1,1,2,3,4,5,6,7,8,[1,2,3]] 4 # L2 = L # 浅拷贝,内存地址不变 5 # L2 = L.copy() #浅拷贝,内存地址变化 6 # L2 = copy.copy(L) #浅拷贝 7 8 L2 = copy.de 阅读全文
posted @ 2021-05-13 17:39 等待iing 阅读(104) 评论(0) 推荐(0)
摘要:1 切片就是list范围取值的一种方式 2 3 取头不取尾 4 5 如: 6 7 li = list(range(0,11)) 8 9 # title = "A man, a plan, a canal: Panama" 10 # a= ''.join(title) 11 # c = a.lower 阅读全文
posted @ 2021-05-13 17:38 等待iing 阅读(242) 评论(0) 推荐(0)
该文被密码保护。
posted @ 2021-05-08 15:42 等待iing 阅读(11) 评论(0) 推荐(0)