Python学习札记
Ubuntu平台下的Python操作Mysql
1.安装Ubuntu,安装Msql.
2.打开终端,输入 python
import MySQLdb
con = MySQLdb.connect(db="python")
cur = con.cursor()
count = cur.execute("select * from test")
print count
data = cur.fetchall()
print data
for d in data:
print d
import os
os.system('clear') # clear screen
count = cur.execute("delete from test where id =1")
print count
count = cur.execute("select * from test")
print count
cur.close()
con.commit()
con.close()
ps.python学习书籍
1.python简明教程
http://www.woodpecker.org.cn:9081/doc/abyteofpython_cn/chinese/
2.python核心编程(第二版)
相关文档:
Python快速入门
目录
1. 第一章 Python快速入门
&nbs ......
1. 第二章 语法及代码约定
&nb ......
最近在研读Python源码剖析一书,此书相当不错,如果自己冲动的去分析Python源码可能会到处碰“鼻”,看到此书时是09年,那时为了研究内存机制才发现有这么一本书,但是工作太忙,根本没时间去分析源码,到了2010年,这是非常有深重意义的一年,所以这一年一定要比之前做的还要付出更多,要想成为技术顶尖就必须研 ......
Python支持ascii字符串,unicode字符串,以及各种字符集,那么它们到底各是什么概念,相互之间存在何种关系呢?
在Python中,ascii字符串,即str类型的值,可能用来表示任意的一块存储空间,那么也就是说,这个字符串内部可以是任何值,例如:可见字符组成的字符串,或者一段二进制数据等。unicode字符串,即unicode类型的 ......
1.1. 语法
1.1.1. if
>>> x=int(raw_input("please enter an integer:"))
please enter an integer:-8
>>> if x<0:
... print 'negative'
... elif x==0:
... print 'zero'
... else:
... print 'positive'
...
negative
这里有几个知识点需要提醒:
1。和 ......