上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 30 下一页
摘要: import smtplib,osfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartimport base64class SendMail(object): def __init__(s 阅读全文
posted @ 2018-03-18 22:42 laosun0204 阅读(101) 评论(0) 推荐(0)
摘要: import smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipart # 发送附件导入MIMEMultipart# username = 'sunshujiang184@163 阅读全文
posted @ 2018-03-18 22:30 laosun0204 阅读(124) 评论(0) 推荐(0)
摘要: import smtplibfrom email.mime.text import MIMETextemail_host = 'smtp.163.com'# 邮件服务器地址email_user = 'sunshujiang184@163.com'# 发送者账号email_pwd = 'a123456 阅读全文
posted @ 2018-03-18 21:40 laosun0204 阅读(109) 评论(0) 推荐(0)
摘要: import threading,time,requestsrun_times = []def blog(): start_time = time.time() r = requests.get('http://www.nnzhp.cn').text # 测试场景 end_time = time.t 阅读全文
posted @ 2018-03-18 21:34 laosun0204 阅读(79) 评论(0) 推荐(0)
摘要: 首先pip install virtualenv,然后就可以使用virtualenv命令了,virtualenv name就可以创建一个文件夹,文件夹里有python的安装路径,新建项目时,选择虚拟的python环境就行,如下图: 点击Create按钮就进入了虚拟环境,虚拟环境就是拷出来的一个副本, 阅读全文
posted @ 2018-03-18 21:27 laosun0204 阅读(185) 评论(0) 推荐(0)
摘要: import multiprocessingimport timedef test(): time.sleep(2) print('over')if __name__ == '__main__': # windows必须加上这行,要不然会报错,mac不用加 for i in range(5): p 阅读全文
posted @ 2018-03-18 21:25 laosun0204 阅读(84) 评论(0) 推荐(0)
摘要: 多个线程操作同一个数据的时候,就得加锁,python3里自动加上锁了 import threadinglock = threading.Lock() # 申请一把锁num = 0def add(): global num # lock.acquire() # 加锁 # # num += 1 # # 阅读全文
posted @ 2018-03-18 21:22 laosun0204 阅读(106) 评论(0) 推荐(0)
摘要: 单线程下载文件: import requestsimport timefrom hashlib import md5def down_load_pic(url): req = requests.get(url) m = md5(url.encode()) with open(m.hexdigest( 阅读全文
posted @ 2018-03-18 10:38 laosun0204 阅读(133) 评论(0) 推荐(0)
摘要: 多线程把六个网站写到文件里(串行) import requests,time,threading def write_html(url,name): r = requests.get(url) with open(name,'w',encoding = 'utf8') as f: f.write(r 阅读全文
posted @ 2018-03-18 10:34 laosun0204 阅读(124) 评论(0) 推荐(0)
摘要: import threading,time def axb(name): time.sleep(1) print('哈哈',name) for i in range(10): t = threading.Thread(target = axb,args = (i,)) # 实例化一个线程,启动一个线 阅读全文
posted @ 2018-03-18 10:33 laosun0204 阅读(139) 评论(0) 推荐(0)
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 30 下一页