Python教程

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

  • #!/usr/bin/env python #coding:utf-8 import os,time,random,threadpool,sys from progressbar import * COUNT=0 tit=1000 PINGIP=[] def main(): ipd=None if len(sys.argv)==2: ipd=sys.argv[1] a=os.popen("ifconfig en0|grep ‘inet ‘|awk ‘{print $2’}") … 继续阅读“python ping网段设备”

    :
  • # coding=utf-8 __author__ = ‘Administrator’ import os tab=’ ‘*4+"|" blank=" "*5 # 存放当前级别目录个数 dict={} # 探测目录深度 def deep(path=None): if path==None: return 0 if path.__len__()==0: return 0 arr = path.split(os.sep) return arr.__len__( … 继续阅读“python 打印目录树”

    :
  • # encoding=utf-8 def printInfo(info): print unicode(info, ‘utf-8’).encode(‘gbk’) class Person(): name = "" def __init__(self, name): self.name = name; return; def Show(self): printInfo("zhuangbanhao%s" % self.name) class Finery(Pe … 继续阅读“python的设计模式”

    :
  • #!/usr/bin/env python # -*- coding: utf-8 -*- ‘ a test module ‘ __author__ = ‘test’ import sys def test(): args = sys.argv if len(args)==1: print ‘Hello, world!’ elif len(args)==2: print ‘Hello, %s!’ % args[1] else: print ‘Too many arguments!’ if __n … 继续阅读“python helloworld”

    :