Python教程
Python教程:包含了所有代写案例以及部分答案
-
import libvirt import os import uuid try: from PIL import Image print("PIL") except ImportError: import Image def handler(stream, buf, opaque): fd = opaque os.write(fd, buf) THUMBNAIL_SIZE =(256, 256) thumbnail = ‘/home/hcc/test/screenshot/ … 继续阅读“python 使用libvirt抓取linux kvm虚拟机的缩略图”
:
-
#!/usr/bin/env python # -*- coding:utf-8 -*- import os,re def main(): fileList=os.listdir(os.getcwd()) p=re.compile(‘\[.*\]’) for fileName in fileList: print(fileName) if ‘[‘ in fileName: os.rename(fileName,p.sub(”,fileName)) #用正则表达式的结果重命名 if fileNa … 继续阅读“python 去掉当前目录下电影名字前的框框”
:
-
# -*- coding:utf-8 -*- class BinDecimal: def printBin(self, num): aa = num*2 rest = [] rest.append(str(int(aa))) while aa != 1: aa = (aa – int(aa))*2 rest.append(str(int(aa))) res = ‘0.’ + "".join(rest) if len(res)>= 32: return "Err … 继续阅读“python 二进制小数”
:
-
抓取超级课程表话题数据。 博文:http://my.oschina.net/jhao104/blog/606922“` python !/usr/local/bin/python2.7 –– coding: utf8 –– “”” 超级课程表话题抓取 “”” import urllib2 from cookielib import CookieJar import … 继续阅读“Python爬虫-抓取手机APP数据”
:
-
def flatten(nested_list): for value in nested_list: if isinstance(value, list): for nested_value in flatten(value): yield nested_value else: yield value def some(nested_list, fn): for value in flatten(nested_list): if fn(value): return value return N … 继续阅读“python 深度搜索+命令模式 解数独”
:
-
# -*- coding: utf-8 -*- import sys reload(sys) import datetime import time sys.setdefaultencoding("utf-8") from ghost import Ghost ghost = Ghost(wait_timeout=20) url="http://weixin.sogou.com/gzh?openid=oIWsFt8JDv7xubXz5E3U41T0eFbk" … 继续阅读“python 微信爬虫”
:
-
很多场景为了不阻塞,都需要异步回调机制。这是一个简单的例子。 python的多线程异步常用到queue和threading模块 #!/usr/bin/env python # -*- coding: UTF-8 -*- import logging import queue import threading def func_a(a, b): return a + b def func_b(): pass def func_c(a, b, c): return a, b, c # 异步任务队列 … 继续阅读“Python多线程异步任务队列(实例)”
:
-
第一种方法: # coding:utf-8 """ 黄哥python远程视频培训班 https://github.com/pythonpeixun/article/blob/master/index.md 黄哥python培训试看视频播放地址 https://github.com/pythonpeixun/article/blob/master/python_shiping.md 咨询qq:1465376564 """ lst = [1 … 继续阅读“python如何将数组分成几个区间,取每个区间的最大值存到另一个数组里”
:
-
from PIL import Image import qrcode #最小尺寸 1 会生成 21 * 21 的二维码,version 每增加 1,生成的二维码就会添加 4 尺寸 #参数 error_correction 指定二维码的容错系数,分别有以下4个系数: #ERROR_CORRECT_L: 7%的字码可被容错 #ERROR_CORRECT_M: 15%的字码可被容错 #ERROR_CORRECT_Q: 25%的字码可被容错 #ERROR_CORRECT_H: 30%的字码可被容错 # … 继续阅读“Python3使用qrcode生成二维码”
:
-
from PIL import Image, ImageFilter, ImageDraw, ImageFont, ImageEnhance, ImageFilter image1 = Image.open(‘C:/Users/hengli/Desktop/1.jpg’) image2 = Image.open(‘C:/Users/hengli/Desktop/2.jpg’) def 图片大小(image): w, h = image.size #获得图片的大小(分辨率) return w, h … 继续阅读“Python3.4 PIL的使用”
: