Python
zxcbnmlei
这个作者很懒,什么都没留下…
展开
-
python 强制int化查询的记录数
当通过这条语句查询出记录数时, sql="select count(*) from tb_cardinfo_user“ 我们会得到一个这样的数据(4L,),不是一个int型数字 所以用if 将之与数字比较,其真值会发生错误; 当用int()强制转化此数据时会报下列错误: int() argument must be a string or a number, not 'tuple'原创 2014-01-03 16:32:58 · 668 阅读 · 0 评论 -
使python程序在Linux下一直运行
使用nohup命令 nohup nohup 命令 用途:LINUX命令用法,不挂断地运行命令。 语法:nohup Command [ Arg ... ] [ & ] 描述:nohup 命令运行由 Command 参数和任何相关的 Arg 参数指定的命令,忽略所有挂断(SIGHUP)信号。在注销后使用 nohup 命令运行后台中的程序。要运行后台中的 nohup 命原创 2014-01-06 18:36:15 · 4222 阅读 · 0 评论 -
Python模块学习 ---- logging 日志记录
许多应用程序中都会有日志模块,用于记录系统在运行过程中的一些关键信息,以便于对系统的运行状况进行跟踪。在.NET平台中,有非常著名的第三方开源日志组件log4net,c++中,有人们熟悉的log4cpp,而在python中,我们不需要第三方的日志组件,因为它已经为我们提供了简单易用、且功能强大的日志模块:logging。logging模块支持将日志信息保存到不同的目标域中,如:保存到日志文件中;以转载 2014-01-20 15:07:09 · 530 阅读 · 0 评论 -
Python 字典存储
rs = [{'a':1,'b':1},{'a':1,'b':2},{'a':2,'b':1},{'a':2,'b':2}] di = {} for data in rs: a = data.get('a') b = data.get('b') if not di.get(a): di[a] = {} if not di原创 2014-04-25 18:00:50 · 2418 阅读 · 0 评论 -
python mssql insert 插入datetime类型
sql="insert into t_goods_charge_log(Goods_Id,Order_Count,User_Id,Rmb,Status,Remark,Charge_Channel_Id,Order_SerialNumber,Adddate) \ values('%d','%d','%d','%d','%d','%s','%d','%s',getdate())" %(goo原创 2014-04-17 16:27:46 · 2061 阅读 · 0 评论 -
Python 列表(list)改成字典(dict)
li = [{'a':1,'b':2},{'a':3,'b':4}...] for data in li:原创 2014-04-18 16:19:28 · 3837 阅读 · 0 评论 -
python twisted reactor 的定时处理
from twisted.internet import reactor import time def main(): reactor.callLater(3,main) print 'Current time is',time.strftime("%H:%M:%S") if __name__ == '__main__': main() re原创 2014-10-20 14:02:18 · 1124 阅读 · 0 评论