Python教程

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”

    :
  • 引入ftplib模块通过ftp发送文件的方法 import ftplib # We import the FTP module session = ftplib.FTP(‘myserver.com’,’login’,’passord’) # Connect to the FTP server myfile = open(‘toto.txt’,’rb’) # Open the file to send session.storbinary(‘STOR toto.txt’, myfile) # Se … 继续阅读“python通过ftp上传文件”

    :