Python论坛  - 讨论区

标题:[python-chinese] 如何让python脚本支持中文?

2004年03月14日 星期日 15:39

d24471 duyuming at huawei.com
Sun Mar 14 15:39:11 HKT 2004

要在表单中输入中文的话,报错更多:÷
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1] Premature end of script headers: default.py, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1] Traceback (most recent call last):
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]   File "D:/Apache Group/Apache2/cgi-bin/default.py", line 36, in ?
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]     document = reader.fromStream( XMLFile )
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]   File "D:\Python23\Lib\site-packages\_xmlplus\dom\ext\reader\PyExpat.py", line 65, in fromStream
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]     success = self.parser.ParseFile(stream)
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1] xml.parsers.expat.ExpatError: unknown encoding: line 1, column 30
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1] Premature end of script headers: addForum.py, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1] Traceback (most recent call last):
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]   File "D:/Apache Group/Apache2/cgi-bin/addForum.py", line 53, in ?
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]     document = reader.fromStream( forumsFile )
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]   File "D:\Python23\Lib\site-packages\_xmlplus\dom\ext\reader\PyExpat.py", line 65, in fromStream
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]     success = self.parser.ParseFile(stream)
, referer: http://localhost/cgi-bin/addforum.py
[Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1] xml.parsers.expat.ExpatError: unknown encoding: line 1, column 30
, referer: http://localhost/cgi-bin/addforum.py

----- Original Message ----- 
From: "Zoom.Quiet" <zoomq at infopro.cn>
To: "d24471" <duyuming at huawei.com>
Cc: <python-chinese at lists.python.cn>
Sent: Sunday, March 14, 2004 3:00 PM
Subject: Re[8]: [python-chinese] 如何让python脚本支持中文?


> Hello d24471,
> 
> 咦咦咦!?
> 错!
> Unicode 是趋势哪!象 Zope 完全可以用 utf-8 进行一切信息的管理!
> 
> 只是,现在相应的编辑软件没有默许支持,主要可能还是输入的问题?
> 
> 而且,我们自个儿编的小软件,没有必要……嗬嗬嗬,没有精力是真 ^__^
> 进行专门的编码处置,除非目标是进行开源软件发布,考虑全球用户的使用…………
> 
> 查一下子 pyiconv 的资料?
> 有专门的项目,支持 Python 的多语言编码的!
> 
> === [ 14:52 ; 04-03-14 ] you wrote:
> 
> d> 书的名称是清华大学出版社2003年6月出版的,原书是deitel出的,可以在网站www.deitel.com上下载相关的资料.
> d> 按你的说法,把编码方式全改为gb2312,就没有问题了,可以正确的写出xml文件.看来utf-8的确不太通用啊.多谢!
> >> 
> 
> === === === === === === === === === === 
> 
> -- 
> Best regards,
>  Zoom.Quiet                            
> 
>  /=======================================\
> ]Time is unimportant, only life important![
>  \=======================================/
> 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月14日 星期日 15:42

Zoom.Quiet zoomq at infopro.cn
Sun Mar 14 15:42:55 HKT 2004

Hello d24471,

使用排除法,确定报怨的功能,代码处,
进行中文化的修正吧!
"""
d> 我总算试出来是怎么回事了,那个论坛脚本很土,它不断对xml文件(论坛本身)进行重写和读取,以记录人员的操作结果。
d> 这样一来,一旦操作中出现错误,就会破坏xml文件结构,引起PyExpat.py的执行错误。
"""

你曾经进行过判断的?
现在首先,你得确认,到底是什么情况下,PyExpat.py 100% 会中断?
真的是中文的问题?



=== [ 15:37 ; 04-03-14 ] you wrote:

d> 目前试着将书中那个论坛的范例全部用gb2312做编码,还是会有报错,
d> 看来问题完全解决还是有一段路啊。
d> 再帮忙看看?多谢!
d> [Sun Mar 14 15:30:10 2004] [error] [client 127.0.0.1] Premature
d> end of script headers: default.py, referer:
d> http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:30:10 2004] [error] [client 127.0.0.1] Traceback (most recent call last):
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:30:10 2004] [error] [client 127.0.0.1]   File
d> "D:/Apache Group/Apache2/cgi-bin/default.py", line 36, in ?
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:30:10 2004] [error] [client 127.0.0.1]    
d> document = reader.fromStream( XMLFile )
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:30:11 2004] [error] [client 127.0.0.1]   File
d> "D:\Python23\Lib\site-packages\_xmlplus\dom\ext\reader\PyExpat.py",
d> line 65, in fromStream
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:30:11 2004] [error] [client 127.0.0.1]    
d> success = self.parser.ParseFile(stream)
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:30:11 2004] [error] [client 127.0.0.1]
d> xml.parsers.expat.ExpatError: unknown encoding: line 1, column 30
d> , referer: http://localhost/cgi-bin/addforum.py

d> ----- Original Message ----- 
d> From: "Zoom.Quiet" <zoomq at infopro.cn>
d> To: "d24471" <duyuming at huawei.com>
d> Cc: <python-chinese at lists.python.cn>
d> Sent: Sunday, March 14, 2004 3:00 PM
d> Subject: Re[8]: [python-chinese] 如何让python脚本支持中文?


>> Hello d24471,
>> 
>> 咦咦咦!?
>> 错!
>> Unicode 是趋势哪!象 Zope 完全可以用 utf-8 进行一切信息的管理!
>> 
>> 只是,现在相应的编辑软件没有默许支持,主要可能还是输入的问题?
>> 
>> 而且,我们自个儿编的小软件,没有必要……嗬嗬嗬,没有精力是真 ^__^
>> 进行专门的编码处置,除非目标是进行开源软件发布,考虑全球用户的使用…………
>> 
>> 查一下子 pyiconv 的资料?
>> 有专门的项目,支持 Python 的多语言编码的!
>> 
>> === [ 14:52 ; 04-03-14 ] you wrote:
>> 
>> d>
>> 书的名称是清华大学出版社2003年6月出版的,原书是deitel出的,可以在网站www.deitel.com上下载相关的资料.
>> d>
>> 按你的说法,把编码方式全改为gb2312,就没有问题了,可以正确的写出xml文件.看来utf-8的确不太通用啊.多谢!
>> >> 
>> 
>> === === === === === === === === === === 
>> 
>> -- 
>> Best regards,
>>  Zoom.Quiet                            
>> 
>>  /=======================================\
>> ]Time is unimportant, only life important![
>>  \=======================================/
>> 

=== === === === === === === === === === 

-- 
Best regards,
 Zoom.Quiet                            

 /=======================================\
]Time is unimportant, only life important![
 \=======================================/



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月14日 星期日 15:45

Zoom.Quiet zoomq at infopro.cn
Sun Mar 14 15:45:00 HKT 2004

Hello d24471,

web 表单提交时候,也有编码问题的哪!
你是URL 带参数发送的?
还是form 的 HTTP send 方式?
后者,可以带编码声明的!

=== [ 15:39 ; 04-03-14 ] you wrote:

d> 要在表单中输入中文的话,报错更多:÷
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1] Premature
d> end of script headers: default.py, referer:
d> http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1] Traceback (most recent call last):
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]   File
d> "D:/Apache Group/Apache2/cgi-bin/default.py", line 36, in ?
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]    
d> document = reader.fromStream( XMLFile )
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]   File
d> "D:\Python23\Lib\site-packages\_xmlplus\dom\ext\reader\PyExpat.py",
d> line 65, in fromStream
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]    
d> success = self.parser.ParseFile(stream)
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:24 2004] [error] [client 127.0.0.1]
d> xml.parsers.expat.ExpatError: unknown encoding: line 1, column 30
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1] Premature
d> end of script headers: addForum.py, referer:
d> http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1] Traceback (most recent call last):
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]   File
d> "D:/Apache Group/Apache2/cgi-bin/addForum.py", line 53, in ?
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]    
d> document = reader.fromStream( forumsFile )
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]   File
d> "D:\Python23\Lib\site-packages\_xmlplus\dom\ext\reader\PyExpat.py",
d> line 65, in fromStream
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]    
d> success = self.parser.ParseFile(stream)
d> , referer: http://localhost/cgi-bin/addforum.py
d> [Sun Mar 14 15:37:37 2004] [error] [client 127.0.0.1]
d> xml.parsers.expat.ExpatError: unknown encoding: line 1, column 30
d> , referer: http://localhost/cgi-bin/addforum.py

d> ----- Original Message ----- 
d> From: "Zoom.Quiet" <zoomq at infopro.cn>
d> To: "d24471" <duyuming at huawei.com>
d> Cc: <python-chinese at lists.python.cn>
d> Sent: Sunday, March 14, 2004 3:00 PM
d> Subject: Re[8]: [python-chinese] 如何让python脚本支持中文?


>> Hello d24471,
>> 
>> 咦咦咦!?
>> 错!
>> Unicode 是趋势哪!象 Zope 完全可以用 utf-8 进行一切信息的管理!
>> 
>> 只是,现在相应的编辑软件没有默许支持,主要可能还是输入的问题?
>> 
>> 而且,我们自个儿编的小软件,没有必要……嗬嗬嗬,没有精力是真 ^__^
>> 进行专门的编码处置,除非目标是进行开源软件发布,考虑全球用户的使用…………
>> 
>> 查一下子 pyiconv 的资料?
>> 有专门的项目,支持 Python 的多语言编码的!
>> 
>> === [ 14:52 ; 04-03-14 ] you wrote:
>> 
>> d>
>> 书的名称是清华大学出版社2003年6月出版的,原书是deitel出的,可以在网站www.deitel.com上下载相关的资料.
>> d>
>> 按你的说法,把编码方式全改为gb2312,就没有问题了,可以正确的写出xml文件.看来utf-8的确不太通用啊.多谢!
>> >> 
>> 
>> === === === === === === === === === === 
>> 
>> -- 
>> Best regards,
>>  Zoom.Quiet                            
>> 
>>  /=======================================\
>> ]Time is unimportant, only life important![
>>  \=======================================/
>> 

=== === === === === === === === === === 

-- 
Best regards,
 Zoom.Quiet                            

 /=======================================\
]Time is unimportant, only life important![
 \=======================================/



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月14日 星期日 16:06

d24471 duyuming at huawei.com
Sun Mar 14 16:06:36 HKT 2004

怎么看cgi是如何发送消息的呢?
我是新手,很多东西不了解,还望大家多指教!谢谢!
----- Original Message ----- 
From: "Zoom.Quiet" <zoomq at infopro.cn>
To: "d24471" <duyuming at huawei.com>
Cc: "Zoom.Quiet" <zoomq at itcase.com>; <python-chinese at lists.python.cn>
Sent: Sunday, March 14, 2004 3:45 PM
Subject: Re[10]: [python-chinese] 如何让python脚本支持中文?


> Hello d24471,
> 
> web 表单提交时候,也有编码问题的哪!
> 你是URL 带参数发送的?
> 还是form 的 HTTP send 方式?
> 后者,可以带编码声明的!
> 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2004年03月14日 星期日 17:07

Zoom.Quiet zoomq at infopro.cn
Sun Mar 14 17:07:40 HKT 2004

Hello d24471,

咦咦咦?
CGI 只能在服务端执行,不能发送什么的!?
表单提交,属于HTML 的范畴,
你得看一看相关的知识了,

其实就是IE处的HTML 页面如何与服务端CGI 程序交互的问题!
你得根据具体情况,进行判定,因为 各有 花招的!

=== [ 16:06 ; 04-03-14 ] you wrote:

d> 怎么看cgi是如何发送消息的呢?
d> 我是新手,很多东西不了解,还望大家多指教!谢谢!
d> ----- Original Message ----- 
d> From: "Zoom.Quiet" <zoomq at infopro.cn>
d> To: "d24471" <duyuming at huawei.com>
d> Cc: "Zoom.Quiet" <zoomq at itcase.com>;
d> <python-chinese at lists.python.cn>
d> Sent: Sunday, March 14, 2004 3:45 PM
d> Subject: Re[10]: [python-chinese] 如何让python脚本支持中文?


>> Hello d24471,
>> 
>> web 表单提交时候,也有编码问题的哪!
>> 你是URL 带参数发送的?
>> 还是form 的 HTTP send 方式?
>> 后者,可以带编码声明的!
>> 

=== === === === === === === === === === 

-- 
Best regards,
 Zoom.Quiet                            

 /=======================================\
]Time is unimportant, only life important![
 \=======================================/



[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号