摘要: 源码举例: 运行结果: 阅读全文
posted @ 2017-09-09 09:15 星瑞 阅读(18795) 评论(0) 推荐(1) 编辑
摘要: 使用HTMLTestRunner运行测试套件,自动生成html测试报告: 1 import unittest, HTMLTestRunner, sendmail_html 2 import time, os 3 4 case_dir = 'D:\\pywork\\pyworkspace\\yzwx_selenium\\batch_case\\test_cases' 5 t = tim... 阅读全文
posted @ 2017-08-22 19:10 星瑞 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 1 # 通过对NC文件复制来造数据 2 import os, shutil 3 4 # 遍历的根目录 5 root_dir = "D:\\test_data\\DISASTER\\" 6 # 获取NC文件的时间 7 time_source = '20161228080000' 8 # 生成NC文件的时间 9 time_new = '201812280... 阅读全文
posted @ 2017-08-13 23:04 星瑞 阅读(2004) 评论(0) 推荐(0) 编辑
摘要: 1 # 多线程举例 2 from threading import Thread 3 from threading import current_thread 4 5 6 class messager(Thread): 7 def run(self): 8 for x in range(20): 9 print(curre... 阅读全文
posted @ 2017-08-13 22:41 星瑞 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 1 # 发送html内容的邮件 2 import smtplib, time, os 3 from email.mime.text import MIMEText 4 from email.header import Header 5 6 7 def send_mail_html(file): 8 '''发送html内容邮件''' 9 # 发送邮箱 10... 阅读全文
posted @ 2017-08-13 22:39 星瑞 阅读(16283) 评论(0) 推荐(0) 编辑
摘要: 1 import logging 2 3 4 # 简单打印日志举例 5 logging.basicConfig(level=logging.DEBUG) # 设置日志级别,WARN 6 logging.warning('Watch out!') # will print a message to the console 7 logging.info('I told yo... 阅读全文
posted @ 2017-08-12 23:03 星瑞 阅读(2965) 评论(0) 推荐(1) 编辑
摘要: 使用os模块查询指定目录下的最新文件 1 import os 2 3 # 输入目录路径,输出最新文件完整路径 4 def find_new_file(dir): 5 '''查找目录下最新的文件''' 6 file_lists = os.listdir(dir) 7 file_lists.sort(k 阅读全文
posted @ 2017-08-12 22:23 星瑞 阅读(10607) 评论(0) 推荐(1) 编辑
摘要: 运行结果: 阅读全文
posted @ 2017-08-12 22:17 星瑞 阅读(358) 评论(0) 推荐(0) 编辑
摘要: Counter类:计算序列中出现次数最多的元素 运行结果: 阅读全文
posted @ 2017-08-12 21:31 星瑞 阅读(2770) 评论(0) 推荐(0) 编辑
摘要: 文件系统操作(os模块) 运行结果: 文件遍历: 遍历目录下所有文件包括子目录 os.walk功能:递归遍历目录下的文件和子目录,参数(需要遍历的目录,排序=ture为顺序) 返回三个值:当前目录、当前目录下的目录列表和当前目录下的文件列表 运行结果: 阅读全文
posted @ 2017-08-12 21:22 星瑞 阅读(849) 评论(0) 推荐(0) 编辑
摘要: 运行截图: 阅读全文
posted @ 2017-08-12 21:13 星瑞 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 自动保存图表:pyplot.savefig('D:\\pic.png'),替代了 pyplot.show()。 1 # 使用matplotlib.pyplot.scatter绘制散点 2 import matplotlib.pyplot as plt 3 from pylab import mpl 4 5 # 设置默认字体,解决中文显示乱码问题 6 mpl.rcParams['fo... 阅读全文
posted @ 2017-08-06 22:58 星瑞 阅读(1650) 评论(0) 推荐(0) 编辑
摘要: 运行结果: 阅读全文
posted @ 2017-08-06 22:54 星瑞 阅读(597) 评论(0) 推荐(0) 编辑
摘要: 运行结果: 阅读全文
posted @ 2017-08-06 22:46 星瑞 阅读(271) 评论(0) 推荐(0) 编辑
摘要: 运行结果: 阅读全文
posted @ 2017-08-06 22:34 星瑞 阅读(274) 评论(0) 推荐(0) 编辑