python的強(qiáng)悍:)
昨天的問題,終于知道了,是oracle8搞的鬼,懶的再去找什么驅(qū)動(dòng)了。便想起了python
幸好張駿 的幫忙,讓我從一知半解到寫出代碼。
用python的代碼明顯簡(jiǎn)潔多了,而且我喜歡代碼的靈活。
import cx_Oracle def parse(): '''generate the content html''' sql = '''select t.bz_code code, t.bz_title title, t.bz_content content from bz_czzs t order by t.bz_code''' connection = cx_Oracle.connect( 'etasadmin/etasadmin@zhongju' ) cursor = connection.cursor() cursor.execute(sql) item=cursor.fetchone() i=1; print 'begin' while item: i+=1 print 'parsing ',i,' item....' writeContent(item[0],item[1],str(item[2])) item=cursor.fetchone() print 'end' def writeContent(code,title,content): filename='D:\\workspace\\style\\test\\content_body.html' s = getContent(code,title,content) out = open(filename,'a') out.write(s) out.flush() out.close() if __name__=='__main__': print 'parse..................' parse() print 'end'
看樣子,要好好學(xué)習(xí)它了。
python 真棒 o_o
posted on 2005-09-20 11:32 martin xus 閱讀(298) 評(píng)論(1) 編輯 收藏 所屬分類: python