04 2018 档案

摘要:1 def my_db(host,user,passwd,db,sql,port=3306,charset='utf8'): 2 import pymysql 3 coon = pymysql.connect(user=user,host=host,port=port,passwd=passwd, 4 db=db, ... 阅读全文
posted @ 2018-04-26 11:21 荒古、潇潇 阅读(980) 评论(0) 推荐(0)
摘要:1 def my_md5(str): 2 import hashlib 3 new_str = str.encode() 4 m = hashlib.md5()#实例化md5对象 5 m.update(new_str)#加密 6 return m.hexdigest()#获取结果返回 阅读全文
posted @ 2018-04-26 10:51 荒古、潇潇 阅读(236) 评论(0) 推荐(0)
摘要:1 import time #将时间戳转换为标准时间格式 2 def timestamp_to_fomat(timestamp=None,format='%Y-%m-%d %H:%M:%S'): 3 #默认返回当前格式化好的时间 4 #传入时间戳的话,把时间戳转换成格式化好的时间,返回 5 if timestamp: 6 time_tuple ... 阅读全文
posted @ 2018-04-25 14:25 荒古、潇潇 阅读(9810) 评论(0) 推荐(0)
摘要:python自带的一些函数,直接拿过来能用的id() #看内存地址type() #看数据类型print() #打印input() #输入list() #转listset()# 转集合str()#转字符串dict()#转字典int()#转intfloat()#转float类型len()#取长度max()min()dir() #帮助你的sorted()#排序round(11.00011,2)#保留几... 阅读全文
posted @ 2018-04-19 14:37 荒古、潇潇 阅读(207) 评论(0) 推荐(0)
摘要:自己写了个生成随机密码的小程序,如下: 如果密码是6-11位的话,可以让密码位数也随机生成: 阅读全文
posted @ 2018-04-10 14:25 荒古、潇潇 阅读(1377) 评论(0) 推荐(0)
摘要:1 import string 2 import random 3 4 print(string.ascii_lowercase) #输出所有的小写字母 5 6 L1 = random.sample(string.ascii_lowercase,3) #随机取3个值,成一个新的数组 7 8 L2 = ''.join(L1) #将数组内的值用空格连接 9 10 print... 阅读全文
posted @ 2018-04-02 14:12 荒古、潇潇 阅读(4009) 评论(0) 推荐(0)