摘要: 1 import os 2 对操作系统的一些操作 3 print(os.getcwd())#获取当前工作目录 4 print(os.makedirs("nhy/py")) #递归创建文件夹,父目录不存在时候创建父目录 5 print(os.mkdir("www")) #创建文件夹 6 makedirs 创建文件夹的时候,如果父目录不存在会自动帮你创建父目录,如果 7 存在,就直接创... 阅读全文
posted @ 2018-06-07 16:46 暮色森森 阅读(226) 评论(0) 推荐(0) 编辑
摘要: GIL 与 Python 线程的纠葛 GIL 是什么东西?它对我们的 python 程序会产生什么样的影响?我们先来看一个问题。运行下面这段 python 程序,CPU 占用率是多少? # 请勿在工作中模仿,危险:) def dead_loop(): while True: pass dead_lo 阅读全文
posted @ 2018-05-29 16:40 暮色森森 阅读(2275) 评论(0) 推荐(1) 编辑
摘要: 1 import pymysql 2 class Mydb(object): 3 def __init__(self,host,user,passwd,db,port=3306,charset='utf8'): 4 try: 5 self.coon = pymysql.connect( 6 host = ... 阅读全文
posted @ 2018-05-22 14:39 暮色森森 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 1 import yagmail 2 username = '######@163.com' 3 passwd = '######' 4 mail = yagmail.SMTP( 5 user=username, 6 password=passwd, 7 host='smtp.163.com', 8 smtp_ssl=True 9 )#smtp_... 阅读全文
posted @ 2018-05-21 18:59 暮色森森 阅读(712) 评论(0) 推荐(0) 编辑
摘要: python中字符串拼接除了用‘+’还可以用%s占位符。 阅读全文
posted @ 2018-05-16 17:19 暮色森森 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1 import requests 2 3 1.发送get请求 4 url = 'http:///api/user/stu_info' 5 data = {'stu_name':'小黑'} #请求数据 6 req = requests.get(url,params=data) #发送get请求 7 print(req.json()) #字典 单引号' 8 print(req.t... 阅读全文
posted @ 2018-05-15 14:00 暮色森森 阅读(2643) 评论(0) 推荐(0) 编辑
摘要: 1 import xlrd 2 book = xlrd.open_workbook('app_student.xls') 3 sheet = book.sheet_by_index(0) 4 # sheet2 = book.sheet_by_name('shee1') 5 # print(sheet.cell(0,0).value) #指定sheet页里面行和lie获取数据 6 # ... 阅读全文
posted @ 2018-05-11 21:24 暮色森森 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 1 import pymysql,xlwt 2 def export_excel(table_name): 3 host, user, passwd, db = '118.24.3.40', 'jxz', '123456', 'jxz' 4 coon = pymysql.connect(user=user,host=host,port=3306,passwd=passwd... 阅读全文
posted @ 2018-05-11 21:23 暮色森森 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1 import hashlib,pymysql,datetime 2 def my_db(sql): 3 import pymysql 4 coon = pymysql.connect( 5 host = '118.24.3.40',user = 'jxz',passwd = '123456', 6 port = 3306,db = ... 阅读全文
posted @ 2018-05-07 15:13 暮色森森 阅读(1457) 评论(0) 推荐(0) 编辑
摘要: 1.把时间戳转换成时间格式,然后返回 2.把格式化的时间转换成时间戳 阅读全文
posted @ 2018-05-03 14:20 暮色森森 阅读(156) 评论(0) 推荐(0) 编辑