Python学习积累《二》

1.Python学习积累《二》 Python的内省机制
http://blog.csdn.net/achang21/article/details/6793450

2.Python 命名规范

http://my.oschina.net/hcp/blog/40979

3. Python模块学习 ---- httplibHTTP协议客户端实现

http://blog.csdn.net/JGood/article/details/4317416

http://www.sandzhang.com/blog/2010/04/09/pyhon-use-httplib-send-http-get-post/

http://blog.sina.com.cn/s/blog_524524850100vfbj.html (提交表单数据)
4. Python中 函数返回多个值

 class MultiReturn:

    def__init__(self,name,age):

       self.Name=name

       self.Age=age

    def printinfo(self):

       return self.Name,self.Age

test=MultiReturn('Cheers Li',29)

aa=test.printinfo()

print aa[0]

print aa[1]

5. Python 从数据读取数据,并逐行写入到文本文件。
import MySQLdb

f=open('D:\\temp\\testdata\\test1.txt','w')
conn =MySQLdb.connect(host=" 192.168.1.23",\
                        user=" root", \
                        passwd=" password", \
                        db=" sstestpfm1")
cursor = conn.cursor()
cursor.execute(" select fileserver_user.identifier fromfileserver_user;")
for row in cursor.fetchall():
    for pair in zip(row):
        a='%s'%pair
        printa
        f.write(a+'\n')        
f.close()
cursor.close()
conn.close()




 

 

你可能感兴趣的:(Python学习积累《二》)