随笔分类 -  Python

摘要:1、python执行sql语句时报错: ValueError: unsupported format character 'y' (0x79) at index 75 date_format(NOW(),'%y%m%d%h%m%s') sql语句中时间格式化%Y与python的参数%s冲突,改成da 阅读全文
posted @ 2022-01-07 15:36 萱娃 阅读(254) 评论(0) 推荐(0) 编辑
摘要:import threading import time def test1(): print(1+5) def test2(): print(5+8) def test3(): print(5 + 8) def test4(): print(5 + 8) def test5(): print(5 阅读全文
posted @ 2021-02-10 22:51 萱娃 阅读(1286) 评论(0) 推荐(0) 编辑
摘要:创建闭包: 1、闭包函数必须有内嵌函数; 2、内嵌内部的函数必须引用上一级函数的变量; 3、闭包函数必须返回内嵌函数 def closure_func(): in_func="in test" def f(): return in_func return fff=closure_func() #此时 阅读全文
posted @ 2021-02-10 19:33 萱娃 阅读(85) 评论(0) 推荐(0) 编辑
摘要:最近因为工作需要,需要在linux上去执行python代码,但是在执行的时候提示cannot import name request,我以为是导入有问题,然后我就把代码放到与包一个目录下,执行py问题提示语法错误,request.py文件里的代码有语法错误,我就纳闷了,不应该啊, 网上找资料一直没找 阅读全文
posted @ 2018-04-05 21:33 萱娃 阅读(1016) 评论(0) 推荐(0) 编辑
摘要:环境是python3.6+selenium 3.4.3+chrome64 在编写前端自动化脚本时使用implicitly_wait时不起作用 1、确认自己是否正确使用,可用简单的例子来测试,比如: 此例子是正常情况 def test(): driver.implicitly_wait(10) dri 阅读全文
posted @ 2018-02-24 15:30 萱娃 阅读(1620) 评论(0) 推荐(0) 编辑
摘要:a=[i for i in range(1,10) if i%2==0]print(a)c=[(x,y) for x in range(5) if x%2==0 for y in range(5) if y%2==1]print(c) M=[[1,2,3],[4,5,6],[7,8,9]]N=[[2 阅读全文
posted @ 2018-02-23 16:08 萱娃 阅读(232) 评论(0) 推荐(0) 编辑
摘要:def list_test(a): list1=[] def list_all_dict(a): #检测字段类型 if isinstance(a,dict): for x in range(len(a)): temp_key=list(a.keys())[x] temp_value=a[temp_k 阅读全文
posted @ 2018-02-22 17:38 萱娃 阅读(580) 评论(0) 推荐(0) 编辑
摘要:from xlrd import open_workbookfrom xlutils.copy import copy jsonfile=r'C:\Users\Administrator\Desktop\en.json'jsonread=open(jsonfile,'r',encoding='UTF 阅读全文
posted @ 2018-02-09 13:49 萱娃 阅读(229) 评论(0) 推荐(0) 编辑
摘要:TypeError: ReadExcelList() takes exactly 1 argument (2 given) 传入的参数有问题 阅读全文
posted @ 2016-11-01 21:00 萱娃 阅读(144) 评论(0) 推荐(0) 编辑
摘要:异常处理 http://www.jb51.net/article/95033.htm 文件常用操作 http://www.jb51.net/article/92946.htm 阅读全文
posted @ 2016-10-20 16:41 萱娃 阅读(144) 评论(0) 推荐(0) 编辑
摘要:class Base(object): def __init__(self): print 'Base create' class childB(Base): def __init__(self): print 'creat B ', super(childB, self).__init__() c 阅读全文
posted @ 2016-10-20 16:29 萱娃 阅读(2578) 评论(0) 推荐(0) 编辑
摘要:1、如下方式去查询无法查询出结果,但直接在数据库查询中去查询是能查询到结果的,郁闷中,花了很久的时间才知道原来是双引号导致的 把:name="%s" 中的%s前后的双引号去掉就对了 2、通过自己写的方法去查询数据库的数据时必须要用到cur.fetchall(),不然查询的结果显示不出,很多时候容易忘 阅读全文
posted @ 2016-09-01 16:33 萱娃 阅读(3881) 评论(0) 推荐(0) 编辑
摘要:def hello(fn): def wrapper(): print "hello" fn() print "goodby" return wrapper@hello #@注解语法糖 # @作用:解释器会解释成下面这样的语句: #test()等价于test=hello(test)def test( 阅读全文
posted @ 2016-08-25 17:38 萱娃 阅读(190) 评论(0) 推荐(0) 编辑
摘要:def mumber(a): def add(b): return a*b return addif __name__=="__main__": c=mumber(2) d=c(5) print d 阅读全文
posted @ 2016-08-25 16:06 萱娃 阅读(172) 评论(0) 推荐(0) 编辑
摘要:http://www.zhihu.com/question/37904398?sort=created&page=2 >>> a = [[1,2],[3,4],[5,6,7]]>>> print sum(a,[])[1, 2, 3, 4, 5, 6, 7] >>> l = [1,2,3]>>> l[ 阅读全文
posted @ 2016-08-25 15:41 萱娃 阅读(187) 评论(0) 推荐(0) 编辑
摘要:今天sql and TO_DAYS( now() ) - TO_DAYS(subscribeTime) = 0 昨天sql and TO_DAYS( now() ) - TO_DAYS(subscribeTime) = 1 本周:YEARWEEK(date_format(create_time,'% 阅读全文
posted @ 2016-08-10 11:37 萱娃 阅读(1209) 评论(0) 推荐(1) 编辑
摘要:dataArray=[(),(),()]alist=[]for i in dataArray: array=[] for j in i: array.append(j) alist.append(array) 更简单的方法就是 alist=[[j for j in i] for i in dataA 阅读全文
posted @ 2016-08-07 20:39 萱娃 阅读(448) 评论(0) 推荐(0) 编辑
摘要:1、查看python中字符或参数的编码 安装chardet模块 chardet文件夹放在site-packages目录下 >>> import chardet >>> chardet.detect("string") 2、 #编码转换过程:原有编码——内部编码——目的编码#decode:把原有编码转 阅读全文
posted @ 2016-05-30 17:23 萱娃 阅读(155) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示