06 2016 档案

摘要:doctest_test.py unittest_test.py 阅读全文
posted @ 2016-06-26 15:11 *飞飞* 阅读(278) 评论(0) 推荐(0) 编辑
摘要:threading_test.py forking_test.py select_test.py poll_test.py twisted_test.py twisted_LineReceiver.py 阅读全文
posted @ 2016-06-26 15:09 *飞飞* 阅读(352) 评论(0) 推荐(0) 编辑
摘要:client_test.py Server_test.py SocketServer.py urllib_test.py 阅读全文
posted @ 2016-06-26 15:04 *飞飞* 阅读(453) 评论(0) 推荐(0) 编辑
摘要:regular.py regular_test.py magnus.txt template.txt 阅读全文
posted @ 2016-06-26 15:01 *飞飞* 阅读(230) 评论(0) 推荐(0) 编辑
摘要:from distutils.core import setup setup(name='hello', version='1.0', description='test example', author='test', py_modules=['hello']) 阅读全文
posted @ 2016-06-26 14:56 *飞飞* 阅读(227) 评论(0) 推荐(0) 编辑
摘要:from tkinter import * def hello():print('hello world') win=Tk() win.title('hello tkinter') win.geometry('200x100') #x不是* btn=Button(win,text='hello',command=hello) btn.pack(expand=YES,fill=BOTH) main... 阅读全文
posted @ 2016-06-26 14:55 *飞飞* 阅读(212) 评论(0) 推荐(0) 编辑
摘要:import sqlite3,sys def convert(value): if value.startswith('~'): return value.strip('~') if not value: value='0' return float(value) conn=sqlite3.connect('food.db') curs=c... 阅读全文
posted @ 2016-06-26 14:53 *飞飞* 阅读(343) 评论(0) 推荐(0) 编辑
摘要:#方法,属性,私有化加双下划线 ''' __a 从外部无法访问,但是类的内部可以访问。实际上还是能在类外访问这些私有方法,尽管不应该这么做:s._A__a 如果不需要使用这种方法但是又不行让其他对象不要访问内部数据,可以使用单下划线 前面有下划线的名字都不会被带星号的imports语句导入 ''' class Person: def setname(self,name): ... 阅读全文
posted @ 2016-06-26 14:51 *飞飞* 阅读(134) 评论(0) 推荐(0) 编辑
摘要:#__init__ 构造方法,双下划线 #__del__ 析构方法,在对象就要被垃圾回收前调用。但发生调用 #的具体时间是不可知的。所以建议尽量避免使用__del__ print('-------example1') class A: def __init__(self): self.a='a' def printA(self): print(se... 阅读全文
posted @ 2016-06-26 14:49 *飞飞* 阅读(138) 评论(0) 推荐(0) 编辑
摘要:#导入模块 import sys sys.path sys.path.append('D:\program files\Python34\PyWorks') #hello.py文件路径 #不用append PyWorks路径也可以,因为D:\program files\Python34在sys.path中 import hello #第一次导入会执行,路径增加... 阅读全文
posted @ 2016-06-26 14:48 *飞飞* 阅读(270) 评论(0) 推荐(0) 编辑
摘要:#文档字符串 def square(x): 'calculates the square of the number x' return x*x square.__doc__ help(square) #列表做实参 #当2个变量同时引用一个列表时,他们的确是同时引一个列表用 #当在序列中做切片时,返回的切片总是一个副本 def change(x): x[0]='**... 阅读全文
posted @ 2016-06-26 14:47 *飞飞* 阅读(275) 评论(0) 推荐(0) 编辑
摘要:try: raise Exception except Exception as e: print(e) try: raise Exception('comment') except Exception as e: print(e) class SomeException(Exception): print('aa') pass try: ... 阅读全文
posted @ 2016-06-26 14:46 *飞飞* 阅读(195) 评论(0) 推荐(0) 编辑
摘要:#链式赋值 m=n=[1,2,3] m[0]=2 print(m,n) #m,n都改变了 x=y='xxx' y='yyy' print(x,y) #只有y 改变 #序列解包 x,y,z=1,2,3 print(x,y,z) try: x,y,z=1,2 #error x,y,z=1,2,3,4 #error except Exception as e: ... 阅读全文
posted @ 2016-06-26 14:44 *飞飞* 阅读(113) 评论(0) 推荐(0) 编辑
摘要:strings=['xxaa','xuo','fwefxxx','woeuxxfei'] print(strings) #替换方法1 for string in strings: if 'xx' in string: index=strings.index(string) strings[index]='00' print(strings) strings... 阅读全文
posted @ 2016-06-26 14:42 *飞飞* 阅读(197) 评论(0) 推荐(0) 编辑
摘要:def hello(): print('hello world') if __name__=='__main__': hello() print("__name__=",__name__,'\n') ''' name=input("what's your name?\n") print("hello, "+name+"!") input("") ''' 阅读全文
posted @ 2016-06-26 14:41 *飞飞* 阅读(174) 评论(0) 推荐(0) 编辑
摘要:http://www.tuicool.com/articles/jIZfaqQ 操作系统环境:Ubuntu 15.10 0.需求原因 想在我的Linux上架设Apache来运行CGI程序,方便以后用Apache部署Python的Web应用,但遇到各种各样的问题,网上找的答案要么都太旧了(4/5年前跟 阅读全文
posted @ 2016-06-03 16:25 *飞飞* 阅读(11427) 评论(4) 推荐(0) 编辑