摘要: cursor.execute("insert into users set email=%s,pwd=%s,nicheng=%s,createtime=%s",(email,pwd,nicheng,time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))) python中时间日期格式化符号: %y 两位数的年份表示(00-9... 阅读全文
posted @ 2017-11-06 21:04 时间影像 阅读(841) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*- import _thread from time import sleep, ctime def fun1(): sleep(2) print('aaaaaaaaaa') def fun2(): sleep(1) print('bbbbbbbbb') def main(): _thread.star... 阅读全文
posted @ 2017-11-06 21:03 时间影像 阅读(79) 评论(0) 推荐(0) 编辑
摘要: # encoding: UTF-8import re#match是否在起始位置找到point = re.match('www','www.runoob.com').span()print point#是否包含point = re.search('com', 'www.run.com.oob.com' 阅读全文
posted @ 2017-11-02 16:53 时间影像 阅读(131) 评论(0) 推荐(0) 编辑
摘要: #分支语句 x=0 if x>> for char in 'hello': print char >>> for ii in range(10): #输出0~9 print ii >>> for ii in range(1,11): #输出1到10 print ii >>> for ii in range(1,11,2): #range([star... 阅读全文
posted @ 2017-11-02 16:52 时间影像 阅读(117) 评论(0) 推荐(0) 编辑
摘要: # -*- coding: utf-8 -*- ''' 使用语法糖@来装饰函数,相当于“myfunc = deco(myfunc)” 但发现deco函数只在第一次被调用,且myfunc函数在第一次后又被多调用了一次 ''' def deco(func): print("before myfunc() called.") func() print(" aft... 阅读全文
posted @ 2017-11-02 16:51 时间影像 阅读(83) 评论(0) 推荐(0) 编辑
摘要: #函数: >>> def sum(a,b): return a+b >>> print sum(5,6) 全局变量 conn = None def openConn(): global conn #全局 aa = None def fun(): global aa #声明aa是全局变量 aa=99 fun() print aa #输出99 默认值 多个返... 阅读全文
posted @ 2017-11-02 16:50 时间影像 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 字符串与元组的区别 相同点:都不可改变。都可以进行切片。 不同点:字符串有很多方法 元祖可以包含字符串 类型不同。字符串是文本型,元祖是序列。 Python 字符串操作(截取/替换/查找/分割) # 例1:字符串截取 str = '12345678' print str[0:1] >> 1 # 输出str位置0开始... 阅读全文
posted @ 2017-11-02 16:49 时间影像 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #分支语句 x=0 if x>> for char in 'hello': print char >>> for ii in range(10): #输出0~9 print ii >>> for ii in range(1,11): #输出1到10 print ii >>> for ii in range(1,11,2): #range([star... 阅读全文
posted @ 2017-11-02 16:49 时间影像 阅读(138) 评论(0) 推荐(0) 编辑