会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
3one
博客园
首页
新随笔
联系
订阅
管理
上一页
1
2
2016年6月20日
python mysql基本操作
摘要: #链接mysql#插入数据import MySQLdbconn = MySQLdb.connect(host = '127.0.0.1',user = 'root',passwd = '',db = 'mytest')cur = conn.cursor()reConn = cur.execute("
阅读全文
posted @ 2016-06-20 20:56 3one
阅读(176)
评论(0)
推荐(0)
2016年6月12日
python 异常处理
摘要: 1、异常处理使用Exception类,也可自定义异常 2、异常处理流程: try: pass except Exception,e pass else: pass finally: pass 3、手动触发异常raise
阅读全文
posted @ 2016-06-12 17:08 3one
阅读(93)
评论(0)
推荐(0)
2016年6月8日
面向对象和类
摘要: #!/usr/bin/env python# _*_ coding:utf-8 _*_# 面向对象'''class Province: province = '23个省之一' # 静态字段 # __init__ 是构造函数 def __init__(self, name, capital, lead
阅读全文
posted @ 2016-06-08 16:52 3one
阅读(109)
评论(0)
推荐(0)
2016年5月31日
python 装饰器
摘要: python 装饰器Decorator #在不改变函数代码的情况下,添加功能 import timedef timeDecorator(func): def getTime(args): t0 = time.time() re = func(args)print re print "执行%s耗时%f
阅读全文
posted @ 2016-05-31 22:08 3one
阅读(104)
评论(0)
推荐(0)
2016年5月30日
python 反射(__import__、getattr)
摘要: #反射的作用在于模块导入,函数调用时简化代码 以URL为例: 假设URL的形式是A/B #!/usr/bin/env python# _*_ coding:utf-8 _*_# 常规'''from backend import login,logout,admindata = raw_input('
阅读全文
posted @ 2016-05-30 21:48 3one
阅读(277)
评论(0)
推荐(0)
python 随机数、MD5加密及yield
摘要: # 随机数 生成验证码import random# print random.random()# print random.randint(1, 5)# print random.randrange(1, 5)# temp = random.randint(65, 90)# print chr(te
阅读全文
posted @ 2016-05-30 17:06 3one
阅读(467)
评论(0)
推荐(0)
2016年5月28日
python time模块 时间处理
摘要: import timeimport reprint time.time()print time.localtime()a = 'tm_year=2016, tm_mon=5, tm_mday=28, tm_hour=6, tm_min=51, tm_sec=14, tm_wday=5, tm_yda
阅读全文
posted @ 2016-05-28 17:35 3one
阅读(150)
评论(0)
推荐(0)
python re 正则表达式
摘要: import reresult1 = re.match('\d+', '1sssda22wdasfsa') # 匹配开头print type(result1)print result1if result1: print result1.group()else: print 'nothing'resu
阅读全文
posted @ 2016-05-28 14:40 3one
阅读(245)
评论(0)
推荐(0)
2016年5月27日
python 序列化和反序列化(pickle和json)
摘要: pickle能序列化常规数据类型(元组、列表、字典、集合等),也可以序列化非常规类型(类、函数等),基本上是所以得数据类型,只能python程序使用。 Python file类型在Python是一个特殊的类型。 json 只能序列化常规类型,任何语言都可以。 ###pickle import pic
阅读全文
posted @ 2016-05-27 15:29 3one
阅读(149)
评论(0)
推荐(0)
上一页
1
2
公告