摘要: 1 #从数据库获取数据 2 import pymysql,hashlib 3 import flask,json 4 5 def op_mysql(sql:str): 6 mysql_info = { 7 'host': 'xx.2xx.z.zz0', 8 'port': 3306, 9 'password': 'ssd... 阅读全文
posted @ 2019-06-04 10:40 小仙女白 阅读(3132) 评论(0) 推荐(0) 编辑
摘要: 1 import flask #自己安装 2 import json 3 4 server = flask.Flask(__name__) 5 #启动一个服务,__name__ 代表当前一个py文件的名字 6 #就是把当前文件当作一个服务启起来 7 8 #在这个服务下开发多个接口 9 #路径 10 @server.route('/login')... 阅读全文
posted @ 2019-06-04 10:38 小仙女白 阅读(1896) 评论(0) 推荐(0) 编辑
摘要: 1 # import urllib #python自带 发网络请求的一个模块 [不好用] 2 3 from urllib.request import urlopen 4 from urllib.parse import urlencode 5 import json 6 url = 'http://api.nnzhp.cn/api/user/stu_info' 7 d = {... 阅读全文
posted @ 2019-06-03 16:57 小仙女白 阅读(4082) 评论(0) 推荐(0) 编辑
摘要: 1 #redis 数据存在内存里面的 每秒能支持10w次的读写 2 3 import redis #需要用pip安装该模块 4 5 host = 'xxxxxx' 6 passwd = 'xxxxxxxcc' 7 8 r = redis.Redis(host=host,password=passwd,db=5)#db用来指定哪个数据库,默认用第一个数据库 #0-15 ... 阅读全文
posted @ 2019-06-03 16:45 小仙女白 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 1 l = [] 2 3 #01 02 03 -10 实现补0 4 5 for i in range(1,11): #range 顾头不顾尾 产生1到10 6 l.append(str(i).zfill(2))#zfill 写成2位 不够2位就补0 7 print(l) 8 9 #列表生成式 10 l2 = [str(i).zfill(2) for i in ra... 阅读全文
posted @ 2019-06-03 16:42 小仙女白 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1 一、连接数据库 2 import pymysql 3 4 #写博客的时候要给这些信息打马赛克 5 #ip xxxxxxx 6 #port xxx 7 #user xxx、 8 #password xxx 9 #db xxx 10 11 conn = pymysql.connect(host='xxxxxx',port=3xxx6,user='... 阅读全文
posted @ 2019-05-08 19:01 小仙女白 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 一、写入excel 1 import xlwt #安装xlwt 2 book = xlwt.Workbook() 3 sheet = book.add_sheet('bai') 4 sheet.write(0,0,'姓名')#一个0 是行 ,第二个0是列 5 sheet.write(0,1,'成绩' 阅读全文
posted @ 2019-05-08 18:58 小仙女白 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 1 import time 2 3 #时间戳 1248893 #节省空间 计算时间也方便 4 #格式化好的时间 2019-12-23 12:00:00 5 6 # cur_time = time.time() #获取当前的时间戳 7 # 8 # res = time.strftime('%Y-%m-%d %X') #%X 代表时分秒 #取当前格式化好的时间 9 #... 阅读全文
posted @ 2019-05-08 18:57 小仙女白 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1 import hashlib 2 # import md5 #在python2里边用这个 3 4 s = '1234567' 5 # print(s.encode()) #字符串转成bytes 6 m = hashlib.md5(s.encode()) #加密 7 res = m.hexdigest() #获取加密后的结果 8 print(res) 9 10 #md5... 阅读全文
posted @ 2019-05-08 18:57 小仙女白 阅读(506) 评论(0) 推荐(0) 编辑
摘要: 1 import os 2 3 print(os.getcwd()) #查询当前目录 4 运行结果:E:\LionUIAuto\day6 5 6 os.mkdir(r'E:\LionUIAuto\day5\test') #通过绝对路径来在某个路径下创建目录 7 8 os.chdir(r'C:\Users\dell-3020\Desktop') #改变目录 ... 阅读全文
posted @ 2019-05-08 18:56 小仙女白 阅读(333) 评论(0) 推荐(0) 编辑