import time #时间戳 一串数字 #从unix元年 #格式化好的时间 2020-08-29 17:24:38 print(int(time.time()))#当前的时间戳 print(time.strftime('%Y-%m-%d %H:%M:%S'))#当前格式化好的时间 # 日期 和 Read More
posted @ 2021-12-26 20:45 捞铁 Views(995) Comments(0) Diggs(0) Edit
import os #获取某个目录下的内容 返回list # ['a.json', 'a.py', 'b.py', 'lhy.py', 'os模块.py']等等 print(os.listdir(r'D:\python高级编程\tmz2020\day5')) os.mkdir('python') # Read More
posted @ 2021-12-26 20:44 捞铁 Views(31) Comments(0) Diggs(0) Edit
1、写一个删除日志的脚本,把三天前的日志并且为空的日志删除生成日志脚本 def timestamp_to_str(timestamp=None,format='%Y-%m-%d %H:%M:%S'): '''时间戳转格式化好的时间,如果没有传时间戳,就获取当前的格式化时间''' if timesta Read More
posted @ 2021-12-26 20:43 捞铁 Views(53) Comments(0) Diggs(0) Edit
import yamail #上传到了pip源 # import yagmail #发附件的附件如果是中文名,是乱码 # yagmail smtp = yamail.SMTP( host='smtp.qq.com',#改成自己邮箱的邮箱的服务器即可 user='xxxx@qq.com', passw Read More
posted @ 2021-12-26 20:43 捞铁 Views(32) Comments(0) Diggs(0) Edit
# a[4] try: '1'+ '2' 2 / 1 except TypeError as e: print(e) print('出错了') except ZeroDivisionError as e: print('除数不能为0') except IndexError: print('下标错误' Read More
posted @ 2021-12-26 20:42 捞铁 Views(68) Comments(0) Diggs(0) Edit
读excel import xlrd book = xlrd.open_workbook('students.xls') # 用完之后自动关闭 # sheet = book.sheet_by_index(0) sheet = book.sheet_by_name('sheet1') print(bo Read More
posted @ 2021-12-26 20:41 捞铁 Views(247) Comments(0) Diggs(0) Edit
#开发好了一个接口 server #请求接口 client # urllib # url = 'http://127.0.0.1:8999/login?username=niuhanyang2&password=1' # req = request.urlopen(url)#get请求 # # di Read More
posted @ 2021-12-26 20:40 捞铁 Views(125) Comments(0) Diggs(0) Edit
练习1: 写一个函数,传入一个表名,把这个表里面的数据导出到excel中 def export_excel('students'): pass students.xls tools.py模块中: import pymysql,xlwt import traceback,hashlib MYSQL_I Read More
posted @ 2021-12-26 20:40 捞铁 Views(33) Comments(0) Diggs(0) Edit
import hashlib s = 'huoziyang123' + 'sd23$@#%G@#25'#盐 s = s.encode() m = hashlib.sha384(s) #bytes,不可逆 result = m.hexdigest() def my_md5(s): s = str(s) Read More
posted @ 2021-12-26 20:39 捞铁 Views(90) Comments(0) Diggs(0) Edit
redis的基本操作: redis_conf ={ 'host':'192.168.64.128', 'password':'Aa123456', 'db':'0', 'port':6379, 'decode_responses':True # 自动将bytes转换为 string 类型 } r = Read More
posted @ 2021-12-26 20:39 捞铁 Views(85) Comments(0) Diggs(0) Edit