摘要: 1 select counters ,input_user ,hours,minutes,counters/minutes as perMinute,counters/hours as perHour from 2 ( 3 SELECT count(*) counters,`录入员` input_user, 4 timestampdiff(hour, '2013-04-21 14:21:43', '2013-04-21 14:35:12') as 5 hours, 6 timestampdiff(minute, '2013-04-21 14:21:4.. 阅读全文
posted @ 2013-12-11 14:35 zhangxiaodel 阅读(1462) 评论(0) 推荐(0) 编辑
摘要: 综合例子 random,[] 1 # -*- coding: UTF-8 -*- 2 import random; 3 4 5 list=["石头","剪刀","布","ok"] 6 7 guize=[["石头","剪刀"],["剪刀","布"],["布","石头"]] 8 9 while True:10 skey=random.choice(list); #random.randint(1, 1 阅读全文
posted @ 2013-12-11 14:28 zhangxiaodel 阅读(322) 评论(0) 推荐(0) 编辑
摘要: 1 f=open("sql.txt") 2 fout=open("out.txt","w") 3 line=f.readline() 4 while line: 5 print line 6 fout.write(line) 7 line=f.readline() 8 9 f.close()10 fout.close() 1 try: 2 f=open("raw_input.py") 3 lines= f.readlines() 4 print lines 5 f.seek(0) 6 fout=open(" 阅读全文
posted @ 2013-12-11 14:26 zhangxiaodel 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1 for number in range(1,5): 2 print number 3 4 print range(4) 5 # [0, 1, 2, 3] 6 7 8 xx=[x*x for x in range(4)] 9 print xx10 #[0, 1, 4, 9]11 12 xx=[x*x for x in range(4) if x % 3==0]13 print xx14 #[0, 9]15 16 xx=[(x,y) for x in range(3) for y in range(3)]17 print xx18 #[(0, 0), (0, 1), (0, 2... 阅读全文
posted @ 2013-12-11 14:20 zhangxiaodel 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 1 #coding utf-8 2 3 __author__ = 'thinkpad' 4 5 numbers=[1,2,3,4,5,6,7,8,9,10] 6 print(numbers) 7 print len(numbers) 8 #[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 9 10 print numbers[1:10:2]11 #[2, 4, 6, 8, 10]12 13 14 print numbers[2:6]15 #[3, 4, 5, 6]16 17 print numbers[10:2:-2]18 #[10, 8, 6, 4]19 20 阅读全文
posted @ 2013-12-11 14:13 zhangxiaodel 阅读(192) 评论(0) 推荐(0) 编辑
摘要: raw_input1 print "hello world"2 3 name=raw_input("what is your name? ")4 print "hello ["+name +"] !"5 6 raw_input("press to close")raw_input 过滤空值 1 name='' 2 while not name or name.isspace(): 3 name=raw_input('type in your name: ') 4 阅读全文
posted @ 2013-12-11 14:05 zhangxiaodel 阅读(315) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 4 import ordereddict 5 6 list1=['jim','marry','terrence'] 7 list2=[13,15,18] 8 12 def unionListToDict(list1, list2):13 result = ordereddict.OrderedDict()14 for i in range(len(list1)):15 #print list1[i],list2[i]16 result[l... 阅读全文
posted @ 2013-12-11 12:27 zhangxiaodel 阅读(350) 评论(0) 推荐(0) 编辑
摘要: 简单方法声明及调用 1 def hello(name='world', id=0):2 return "hello %s %s" % (name, id)3 4 5 str = hello('kimi', 3)可变参数 1 def nums(a,b,c,*arg,**args): 2 print(a,b,c) 3 print(arg) 4 print(args) 5 6 nums(1,2,3,4,(1,2,3)) 7 8 #输出为 9 (1, 2, 3)10 (4, (1, 2, 3))11 {}字典参数1 #字典需要声明及使用时 2个参数 阅读全文
posted @ 2013-12-11 12:24 zhangxiaodel 阅读(200) 评论(0) 推荐(0) 编辑
摘要: __author__ = 'admin'# -*- coding: utf-8 -*-class Ren(): name="human" def say(self): print('can speak')class Chinese(Ren): name = 'chinese people'#多重继承 使用先继承者的属性 ,可调整顺序实现想要的属性 ,且只#继承第一个的 __init__ 方法class Beijing(Chinese,Ren): passRen.name='a human'print(Ren.n 阅读全文
posted @ 2013-12-11 11:55 zhangxiaodel 阅读(151) 评论(0) 推荐(0) 编辑
摘要: python2.7 在32,64位win7 上字符集是不同的 。在安装easy_install时候会体现出来,会报 mimetypes 错误 ,只需将出错的哪一段代码注释掉。这个问题也困扰了我很久,直到一位老友在国外的某个网站上查到了关于此问题的资料。如下: 1 try: 2 ctype = _winreg.EnumKey(mimedb, i) 3 except EnvironmentError: 4 break 5 # ... 阅读全文
posted @ 2013-12-11 11:47 zhangxiaodel 阅读(175) 评论(0) 推荐(0) 编辑