python
行走在时间里
一点一滴,踏踏实实的工作。
展开
-
Python函数的定义和使用
python定义和引用函数 def printhello(): print 'yuan hui is not' print " a big pig" printhello() 格式: def function(params): block return原创 2014-08-20 13:58:55 · 468 阅读 · 0 评论 -
Python接受命令行参数
1 #!/usr/bin/python 2 #decoding=GBK 3 4 import sys 5 6 for i in range(0, len(sys.argv)): 7 if i==0: 8 print 9 else: 10 print s原创 2014-08-20 15:15:56 · 695 阅读 · 0 评论 -
Python接受网页传递的参数
1 #!/usr/bin/python 2 #decoding=GBK 3 4 import sys 5 6 reload(sys) 7 sys.setdefaultencoding('GBK') 8 9 print 'Content-Type: text/html;charset=GBK \r\n' 10 11 import cgi原创 2014-08-20 15:06:13 · 2321 阅读 · 0 评论 -
Python 连接数据库
python连接数据库1、 下载MySQLdb模块并安装apt-get install MySQLdb2、 导入MySQLdb模块import MySQLdb3、 用MySQLdb.connect建立数据库连接Conn =MySQLdb.connect(host,user,passwd,db )如:conn=MySQLdb.connect("localhos原创 2014-08-20 13:58:45 · 691 阅读 · 0 评论 -
python网页显示
一、使用python,在网页上显示内容,前面需要加载sys模块,设定他的编码即实现这样的操作。 1 #!/usr/bin/python 2 3import sys 4 5reload(sys) 6sys.setdefaultencoding('GBK') 7 8print 'Content-Type: text/html;charset=GBK原创 2014-08-17 09:34:12 · 1339 阅读 · 0 评论 -
python类的定义和使用
Python 类的使用。1. 使用一个名为 __init__的方法来完成初始化。2. 使用一个名为 __del__ 的方法来完成类似析购操作。3. 所有的实例方法都拥有一个 self 参数来传递当前实例,类似于 this。 1 #!/usr/bin/python 2#decoding=GBK 3 4import sys 5 6reload(s转载 2014-08-20 14:29:56 · 540 阅读 · 0 评论 -
python smtp邮件转发
1 #!/usr/bin/python 2 #decoding=utf-8 3 import cgi 4 import sys 5 import smtplib 6 reload(sys) 7 sys.setdefaultencoding('utf-8') 8 print 'Content-Type: text/html;charset=utf-8\r\n原创 2014-10-10 13:32:53 · 1767 阅读 · 0 评论 -
Python对字符串进行处理
1、判断某个字符串中是否含有指定字符原创 2014-08-20 16:23:18 · 883 阅读 · 0 评论