首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python2.7 调用webservice函数中的参数替中文出错

2013-09-25 
python2.7调用webservice函数中的参数为中文出错import sudsimport os, base64urlhttp://localhost:8080

python2.7 调用webservice函数中的参数为中文出错
import suds
import os, base64
url="http://localhost:8080/Test/wsdl/test.wsdl"
client = suds.client.Client(url)
print client

result=client.service.test('shanghai')#没问题
result=client.service.test('上海市')#

下边那句就出错了,为什么?求解 webservice python 中文
[解决办法]
试试 result=client.service.test('上海市'.encode('cp936'))
[解决办法]
'上海市'是byte str,没法encode,用

u'上海市'.encode('cp936')


[解决办法]
文件第一行或第二行加
#coding=utf8
[解决办法]
你的py文件的编码是什么,先转化为utf-8的

然后 u'上海市' 看看

热点排行