上一页 1 ··· 4 5 6 7 8 9 10 11 下一页
  2013年4月19日
摘要: import MySQLdbconn = MySQLdb.connect(host="localhost", \user="root", \passwd="root", \db="TestDB")cursor = conn.cursor()cursor.execute("select * from Users")res = cursor.fetchall()print rescursor.close()conn.close() 阅读全文
posted @ 2013-04-19 19:52 andy071001 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 查看CPU信息(型号)# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 8 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz(看到有8个逻辑CPU, 也知道了CPU型号)# cat /proc/cpuinfo | grep physical | uniq -c 4 physical id : 0 4 physical id : 1(说明实际上是两颗4核的CPU)PS:Jay added on 10th, May, 2011# 其实是可能有超线程HT技术,不一定是有4核,也可能是2核4线程;当时... 阅读全文
posted @ 2013-04-19 10:47 andy071001 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 多人开发时需要在配置文件中加入自己的配置数据库信息,最好不要把自己的数据库密码放入其中,因此可以把本机数据库密码设为空 mysql>use mysqlmysql>update user set password=password('') where user='username';mysql>exit~>mysqladmin -uusername -p -h192.168.1.40 reload注意重载权限表的时候用以前的密码而不是用空密码 阅读全文
posted @ 2013-04-19 10:36 andy071001 阅读(1585) 评论(0) 推荐(0) 编辑
  2013年4月17日
摘要: InnerJoinInnerJoin把两个表连接在一起,返回两个表中相匹配的记录,是2和3的交集。LeftouterjoinLeftouterjoin,左侧表所有的记录都返回,右侧匹配的记录返回,没有匹配的返回NullRightouterjoin与Leftouterjoin相反,右侧的记录返回,左侧返回匹配的记录,没有匹配返回NullFullouterjoin2和3的并集。Crossjoin两个表的笛卡儿积,返回所有可能的值,不允许有连接条件! 阅读全文
posted @ 2013-04-17 13:20 andy071001 阅读(118) 评论(0) 推荐(0) 编辑
  2013年4月12日
摘要: from __future__ import division然后再除就可以了 阅读全文
posted @ 2013-04-12 18:56 andy071001 阅读(579) 评论(0) 推荐(0) 编辑
  2013年4月9日
摘要: git status命令Unmerged paths:下面列出的就是全部冲突文件,挨个解决即可 阅读全文
posted @ 2013-04-09 16:31 andy071001 阅读(18285) 评论(0) 推荐(0) 编辑
摘要: 原文链接:http://www.adminschoice.com/crontab-quick-reference/ 转载请注明译者及原文链接在Unix和Solaris系统中设置计划任务cron是一个unix和solaris系统的功能,主要用于通过cron dameon在后台按照一定的时间间隔来自动执行任务。这些任务在unix,solaris中通常被称作cron job。Crontab(CRON TABle)是一个文件,其中包含要运行的计划条目,以及运行的时间和次数。本文包括了unix cron job如下几个方面的内容:1,Crontab 限制2,Crontab命令3,Crontab文件——语 阅读全文
posted @ 2013-04-09 14:18 andy071001 阅读(329) 评论(0) 推荐(0) 编辑
  2013年4月8日
摘要: str.split("\s")与re.split("\s",str)是不一样的。两者区别如下:1,str.split("\s")是照字面上来按照"\s"字符来分割字符串2,re.split("\s", str)是按照空白来分割,因为正则表达式中的"\s"就是空白space的意思另外,正则表达式中的中括号意为列举,如[abc]则能匹配含有a或b或c的字符串。另外python的lambda(实际来自lisp)则能定义匿名函数:看个例子: 1 g = lambda x:x+1 看一 阅读全文
posted @ 2013-04-08 17:41 andy071001 阅读(2509) 评论(0) 推荐(0) 编辑
  2013年4月3日
摘要: 今天在重构代码时,遇到了一个问题,找了好久才发现是在变量链式赋值的时候出了问题,记下来以免以后再犯。以下是例子:a = b = c = []c = [1,2,3]执行这两条语句之后,查看abc的值:a和b仍然都是[],c已经是[1,2,3]继续:c.append(3)b.append(1)现在看abc的值,c是[1,2,3,3],b是[1],重点来了,a现在也成为了[1]而我们对a没有进行任何地操作,这说明,a和b代表的对象是相同的。那么出现这种情况的原因是什么呢?这是因为python的变量定义的机制。python链式赋值:a = b = c = [],这时候,a,b,c对应的都是同一个内存中 阅读全文
posted @ 2013-04-03 17:37 andy071001 阅读(498) 评论(0) 推荐(0) 编辑
  2013年4月2日
摘要: While join() exclusively deals with the “right” side of the JOIN, we can also control the “left” side, in those cases where it’s needed, using select_from(). Below we construct a query against Address but can still make usage of User.addresses as our ON clause by instructing the Query to select firs 阅读全文
posted @ 2013-04-02 18:04 andy071001 阅读(1220) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 下一页