Python教程

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

  • ”’ print the "Hello, world!" on the console ”’ import os ”’ read data in file ”’ class File: def __init__(self): self.data = os.getcwd()+’\\data.txt’ self.datalines = self.readDataToList() def readDataToList(self): data = [] try: file = … 继续阅读“python初学之helloworld”

    :
  • #coding=utf-8 #异常用法 import sys #—————- #sys.exc_info()[2].tb_lineno值不是固定的 try: x=1/0 except Exception as e: print "Exception:[%s][%s]" % (sys.exc_info()[2].tb_lineno, str(e)) finally: print "This is finally " #———- … 继续阅读“python 演示异常”

    :
  • python 3.4.3 cx_Oracle“` python !/usr/bin/env python import time start = time.clock() import cx_Oracle tns = cx_Oracle.makedsn(‘127.0.0.1’, ‘1534’, ‘dsn’) db = cx_Oracle.connect(‘username’, &#8216 … 继续阅读“Python连接Oracle”

    :
  • class JianKong(): ”’查询IDC信息,封ip和过白名单”’ def __init__(self): pass @classmethod def ip_verify(cls,str): ‘验证IP地址规范’ pattern=re.compile(‘(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1 … 继续阅读“python 匹配IP和匹配域名”

    :
  • 文件型数据库sqllite读写操作:“`python None MySQL数据库读写操作:“`python def ExecSql(sql, dbName="", host="", user="", passwd="", charset=”): import MySQLdb conn = MySQLdb.connect(host=host, user=user, passwd=passwd, char … 继续阅读“Python数据库操作”

    :