考生评语,布衣传说怎么样,嫩白
def out(text):
p = re.compile(r'","')
m = p.split(text)
print m[0][4:].decode('utf-8').encode('gbk')
if __name__=='__main__':
while true:
word=raw_input('input the word you want to search:')
text=urlencode({'text':word})
h=httplib.http('translate.google.cn')
h.putrequest('get', '/translate_a/t?client=t&hl=zh-cn&sl=en&tl=zh-cn&ie=utf-8&oe=utf-8&'+text)
h.endheaders()
h.getreply()
f = h.getfile()
lines = f.readlines()
out(lines[0])
f.close()
haskell版
import network.http
import text.regex.posix
main = do
putstrln "input the word you want to search:"
word <- getline
handle <- simplehttp (getrequest $ "http://translate.google.cn/translate_a/t?client=t&hl=zh-cn&sl=en&tl=zh-cn&ie=utf-8&oe=utf-8&" ++ (text word))
content <- getresponsebody handle
let match = (content =~ "\",\""::(string,string,string))
putstrln $ drop 4 $ first match
main
text word = urlencodevars [("text",word)]
first::(string,string,string)->string
first (x,_,_) = x
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
新手学习Python2和Python3中print不同的用法
Python基于os.environ从windows获取环境变量
网友评论