随笔分类 -  Python实例

摘要:输出结果: 阅读全文
posted @ 2019-01-23 10:54 寒爵 阅读(967) 评论(0) 推荐(0)
摘要:import turtle pen = turtle.Pen() pen.speed(10) width = 30 # 格子宽度 count = 18 # 横向纵向格子数 o = width * count / 2 # 开始绘制原点 for i in range(count + 1): pen.penup() pen.goto(-o, o - i * width) ... 阅读全文
posted @ 2018-11-06 12:14 寒爵 阅读(4705) 评论(0) 推荐(0)
摘要:import time def progress(percent, width=50): ''' 进度打印功能 :param percent: 进度 :param width: 进度条长度 ''' if percent >= 100: percent = 100 show_str = ('[%%-%ds]' % wid... 阅读全文
posted @ 2018-10-08 15:59 寒爵 阅读(2431) 评论(0) 推荐(0)
摘要:import requests from bs4 import BeautifulSoup def parse_html(num): headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0... 阅读全文
posted @ 2018-09-26 16:40 寒爵 阅读(904) 评论(0) 推荐(0)
摘要:from hashlib import md5 def encrypt_md5(s): # 创建md5对象 new_md5 = md5() # 这里必须用encode()函数对字符串进行编码,不然会报 TypeError: Unicode-objects must be encoded before 阅读全文
posted @ 2018-09-19 17:06 寒爵 阅读(7398) 评论(0) 推荐(0)
摘要:输出结果: 阅读全文
posted @ 2018-09-19 16:43 寒爵 阅读(7393) 评论(0) 推荐(1)
摘要:输出结果: 阅读全文
posted @ 2018-09-17 11:31 寒爵 阅读(2412) 评论(0) 推荐(0)