分享一段代码,很简单但是也很实用。 1 #!/usr/bin/python 2 #-*- coding:gb18030 -*- 3 ''' 4 Usage: mq.py [Qmgr] 5 *get the queues' curdepth which type is local,...
分类:
编程语言 时间:
2014-07-16 23:06:47
阅读次数:
226
方法1:import sched, timeimport oss = sched.scheduler(time.time,time.sleep)#scheduler的两个参数用法复杂,可以不做任何更改defplaymusic(x):os.system(x)def jobtodo():tmlist =...
分类:
编程语言 时间:
2014-07-16 23:01:43
阅读次数:
235
1. 写csv文件# coding: utf-8import csvcsvfile = file('csv_test.csv', 'wb')writer = csv.writer(csvfile)writer.writerow(['姓名', '年龄', '电话']) #写入单行data = [ .....
分类:
编程语言 时间:
2014-07-16 22:57:55
阅读次数:
201
1.工厂模式#encoding=utf-8__author__ = 'kevinlu1010@qq.com'class ADD(): def getResult(self,*args): return args[0]+args[1]class SUB(): def getR...
分类:
编程语言 时间:
2014-07-16 22:56:35
阅读次数:
213
上一篇中带参数的URLconf虽然可以做到传参动态显示内容,但是最终现实的内容还是硬编码到Python代码中的1 def hours_ahead(request,phours):2 try:3 phours = int(phours)4 except VauleErr...
分类:
其他好文 时间:
2014-07-12 08:52:40
阅读次数:
154
分享一段代码,很简单但是也很实用。 1 #!/usr/bin/python 2 #-*- coding:gb18030 -*- 3 ''' 4 Usage: mq.py [Qmgr] 5 *get the queues' curdepth which type is local,...
分类:
编程语言 时间:
2014-07-12 08:40:14
阅读次数:
502
http://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/类似俄罗斯轮盘赌
分类:
其他好文 时间:
2014-07-12 08:33:57
阅读次数:
177
分享一段代码,很简单但是也很实用。 1 #!/usr/bin/python 2 #-*- coding:gb18030 -*- 3 ''' 4 Usage: mq.py [Qmgr] 5 *get the queues' curdepth which type is local,...
分类:
编程语言 时间:
2014-07-12 08:05:13
阅读次数:
404
分享一段代码,很简单但是也很实用。 1 #!/usr/bin/python 2 #-*- coding:gb18030 -*- 3 ''' 4 Usage: mq.py [Qmgr] 5 *get the queues' curdepth which type is local,...
分类:
编程语言 时间:
2014-07-12 08:03:54
阅读次数:
373
我采用的是MySQLdb操作的MYSQL数据库。先来一个简单的例子吧:importMySQLdb
try:
conn=MySQLdb.connect(host=‘localhost‘,user=‘root‘,passwd=‘root‘,db=‘test‘,port=3306)
cur=conn.cursor()
cur.execute(‘select*fromuser‘)
cur.close()
conn.close()
exceptMySQLdb.Error,e..
分类:
数据库 时间:
2014-07-10 18:20:40
阅读次数:
282