Python教程
Python教程:包含了所有代写案例以及部分答案
-
python可以通过tarfile模块压缩和解压.tar.bz2包 #压缩文件夹为 .tar.bz2 import tarfile import bz2 archive = tarfile.open(‘myarchive.tar.bz2′,’w:bz2′) archive.debug = 1 # Display the files beeing compressed. archive.add(r’d:\myfiles’) # d:\myfiles contains the files to co … 继续阅读“python压缩和读取.tar.bz2格式的压缩包”
:
-
#python求txt文件中所有Z后面数字的最小值和最大值 #依山居 19:04 2015/11/7 #题目来源: http://www.bathome.net/thread-38027-1-1.html zl=[] with open("a.txt") as f: for l in f: txtline=l.rsplit() for ll in txtline: #print(ll) if ll[0]=="Z": x=float(ll[1:]) zl.a … 继续阅读“python求txt文件中所有Z后面数字的最小值和最大值”
:
-
def quickSort(arg): if(arg==[]): return [] return quickSort([i for i in arg[1:] if i<=arg[0]])+[arg[0]]+quickSort([i for i in arg[1:] if i>arg[0]]) print quickSort([12,14,25,23,2,17,13,25,34,777]) 超级"简短"的python实现的快速排序。我很喜欢这个代码,因为它很纯,很 … 继续阅读“python 快速排序python实现。”
:
-
def get_appsys_by_no(self, no): o_type = self.order_type(no) table_name = "t_order_" + o_type.lower() #: result = db.session.execute("SELECT * FROM %s where no = ‘%s’" %(table_name, no)) result = db.session.execute("SELECT * … 继续阅读“python flask-sqlalchemy”
:
-
#coding=utf-8 import socket #加载socket模块 from time import ctime #加载time模块ctime类 HOST = ” #设置主机IP,为空则表示本机上所有的网卡ip。 PORT = 3300 #设置端口号 BUSIZ = 1024 #设置数据缓冲区,1KB ADDR = (HOST, PORT) def closeTCnt(): # TCntSock.close() print "Session closing.." … 继续阅读“Python 实现半双工聊天器”
:
-
#-*- encoding: utf-8 -*- import logging import sys import os import pygame from pygame.locals import * from hubarcode.code128 import Code128Encoder from PIL import Image,ImageDraw,ImageFont #logging.getLogger("code128").setLevel(logging.DEB … 继续阅读“python生成128条形码(code128)”
:
-
#-*- charset:utf-8 -*- #This program will follow users intention to convert F to C or the contray typeNo = eval(input("Do you want to convert Fah to Cel or convert Cel to Fah,enter 1 for F to C,enter 2 for C to F:")) if typeNo == 1: data = … 继续阅读“python 将华氏温度转换成摄氏温度,或者相反”
:
-
import random Maclist = [] for i in range(1,7): RANDSTR = "".join(random.sample("0123456789abcdef",2)) Maclist.append(RANDSTR) RANDMAC = ":".join(Maclist) print RANDMAC ——————————–运行结果————— … 继续阅读“python 生成随机MAC地址”
: