Python论坛  - 讨论区

标题:[python-chinese] google搜索中关键字的编码

2005年06月12日 星期日 11:37

fei feiyafei at gmail.com
Sun Jun 12 11:37:16 HKT 2005

我最近编的一个程序可能要通过在线搜索,例如搜索关键字“中文”,那么通过
urllib.quote:

>>> urllib.quote('中文')
'%D6%D0%CE%C4'

但是我发现在google中实际上,'中文'对应的字串是“%E4%B8%AD%E6%96%87”。这是
不是因为采用了其他编码?

请问,如何利用能够将'中文'转为“%E4%B8%AD%E6%96%87”让google进行搜索呢?

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

2005年06月12日 星期日 14:41

fei feiyafei at gmail.com
Sun Jun 12 14:41:31 HKT 2005

谢谢你,终于解决了问题。

Qiangning Hong 写道:

>fei wrote:
>  
>
>>我最近编的一个程序可能要通过在线搜索,例如搜索关键字“中文”,那么通过
>>urllib.quote:
>>
>>
>>    
>>
>>>>>urllib.quote('中文')
>>>>>          
>>>>>
>>'%D6%D0%CE%C4'
>>
>>但是我发现在google中实际上,'中文'对应的字串是“%E4%B8%AD%E6%96%87”。这是
>>不是因为采用了其他编码?
>>
>>请问,如何利用能够将'中文'转为“%E4%B8%AD%E6%96%87”让google进行搜索呢?
>>    
>>
>
>urllib.quote(unicode('中文', 'GB18030').encode('UTF-8'))
>
>  
>


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

2005年06月12日 星期日 22:35

Qiangning Hong hongqn at gmail.com
Sun Jun 12 22:35:36 HKT 2005

fei wrote:
> 我最近编的一个程序可能要通过在线搜索,例如搜索关键字“中文”,那么通过
> urllib.quote:
> 
> 
> >>>urllib.quote('中文')
> 
> '%D6%D0%CE%C4'
> 
> 但是我发现在google中实际上,'中文'对应的字串是“%E4%B8%AD%E6%96%87”。这是
> 不是因为采用了其他编码?
> 
> 请问,如何利用能够将'中文'转为“%E4%B8%AD%E6%96%87”让google进行搜索呢?

urllib.quote(unicode('中文', 'GB18030').encode('UTF-8'))

-- 
Qiangning Hong

 ___________________________________________________________
/ There is no substitute for good manners, except, perhaps, \
\ fast reflexes.                                            /
 -----------------------------------------------------------
    \                                  ___-------___
     \                             _-~~             ~~-_
      \                         _-~                    /~-_
             /^\__/^\         /~  \                   /    \
           /|  O|| O|        /      \_______________/        \
          | |___||__|      /       /                \          \
          |          \    /      /                    \          \
          |   (_______) /______/                        \_________ \
          |         / /         \                      /            \
           \         \^\\         \                  /               \     /
             \         ||           \______________/      _-_       //\__//
               \       ||------_-~~-_ ------------- \ --/~   ~\    || __/
                 ~-----||====/~     |==================|       |/~~~~~
                  (_(__/  ./     /                    \_\      \.
                         (_(___/                         \_____)_)

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号