Python教程

Python教程:包含了所有代写案例以及部分答案

  • #沿左,右子节点较大者依次往下调整 def heapify( array, i, n ): j = i * 2 + 1 while j < n: if j + 1 < n and array[j] < array[j + 1]: j += 1 if array[i] > array[j]: break array[i], array[j] = array[j], array[i] i = j j = i * 2 + 1 #创建堆 def build_heap( array … 继续阅读“python实现堆排序”

    :
  • #!/usr/bin/env python #coding:utf-8 import urllib2 import re import os def getHtml(url): #获取html源码 headers={"User-Agent":"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1"} req=urllib2.Request(url,headers=headers) response=urllib … 继续阅读“python 翻页抓取”

    :
  • # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui from PyQt4.QtCore import * from PyQt4.QtGui import * from modules.UrlGet import UrlGet from modules.SameSite import SameSite import resource.resources class Main_Window(QMainWindow): def __init_ … 继续阅读“python web小工具”

    :
  • #!/usr/bin/env python #-*- coding:utf-8-*- from mysql import connector def connect(): config={ ‘host’:’localhost’,#默认127.0.0.1 ‘user’:’root’, ‘password’:’1111111′, ‘port’:3306 ,#默认即为3306 ‘database’:’test’, ‘charset’:’utf8’#默认即为utf8 } try: return conn … 继续阅读“python Mysql connector封装”

    :