- 论坛徽章:
- 1
|
本帖最后由 crykun 于 2012-04-14 18:34 编辑
万能的cu,再次求助。
mod_python3.3.1 rhel 5.4 apache2.0.64环境,写的psp访问数据库的程序,
中文字符显示的是乱码,刷新一次,又正常了。关闭浏览器,输入网址,又是乱码,刷新一次,又正常。
初步排除是数据库字符集和meta <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
想写一个php类似的header()改变http的报头,不知怎么写,可有朋友知道,这是什么原因?或是问题所在?
小弟初学,高人不要笑。
下面是psp程序,一个读取oracle记录的演示程序:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>python oracle中文页</title>
</head>
<body>
<%
import cx_Oracle
import os
req.write('Hello world!')
req.write('<hr>')
req.write('python oracle 中文页')
req.write('<hr>')
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
db = cx_Oracle.connect('system', 'mz123456', '192.168.1.119/orcl')
c = db.cursor()
c.execute('SELECT id,xname FROM mytab order by id')
results = c.fetchall()
for result in results:
req.write ('%s' %result[0])
req.write (',')
req.write ('%s' %result[1])
req.write ('<br>')
db.close()
%>
</body>
</html>
|
|