python 자동화 인터페이스 테스트(바 이 두 번역)

2831 단어 Python
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import sys

url="http://fanyi.baidu.com/v2transapi"
params={
    "from":"en",
    "to":"zh",
    "query":"test"
}
r=requests.request("post",url,params=params)
#print(r.text)
import json
d=json.loads(r.text)
c=d['liju_result']['tag']
c_convert=''.join(c)
list=list(c_convert)
msg=repr([x.encode(sys.stdout.encoding)for x in c]).decode('string -escape')#   encode list     
print c
print c_convert
print msg
print list

[u'\u8bd5\u9a8c', u'\u6d4b\u9a8c', u'\u8003\u9a8c', u'\u5316\u9a8c', u'\u8003\u67e5', u'\u53d7\u8bd5\u9a8c', u'\u53d7\u6d4b\u9a8c', u'\u53d7\u8003\u9a8c', u'\u6d4b\u5f97\u7ed3\u679c']
                       
['  ', '  ', '  ', '  ', '  ', '   ', '   ', '   ', '    ']
[u'\u8bd5', u'\u9a8c', u'\u6d4b', u'\u9a8c', u'\u8003', u'\u9a8c', u'\u5316', u'\u9a8c', u'\u8003', u'\u67e5', u'\u53d7', u'\u8bd5', u'\u9a8c', u'\u53d7', u'
 
  
\u6d4b', u'\u9a8c', u'\u53d7', u'\u8003', u'\u9a8c', u'\u6d4b', u'\u5f97', u'\u7ed3', u'\u679c']

좋은 웹페이지 즐겨찾기