hujh20 发表于 2017-4-22 13:35:18

python的强悍:)

  昨天的问题,终于知道了,是oracle8搞的鬼,懒的再去找什么驱动了。便想起了python
幸好张骏 的帮忙,让我从一知半解到写出代码。
  用python的代码明显简洁多了,而且我喜欢代码的灵活。

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,item,str(item))
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'

  看样子,要好好学习它了。
python 真棒 o_o
<!----><!----><!---->
页: [1]
查看完整版本: python的强悍:)