See a small partner to share the Turing man Python play, think very interesting
On Linux, you can try a simpler approach. For example, using curl to command curl
"Key&info= chat content requested by http://www.tuling123.com/openapi/api?key="
For example: Curl "Http://www.tuling123.com/openapi/api?key=fskfjaslfjals&info=hello"
#!/usr/bin/python #-- Coding:utf8- -ImportOSImportJSONImportUrllib2classChat (object): Key="the key for the application" #turing123 websiteApiurl ="Http://www.tuling123.com/openapi/api?"definit (self): Os.system ("Clear") Print "give it a go!" Print "-------------------------------"defGet (self):Print ">", Info=raw_input ()ifinfo = = ('Q' or 'Exit' or "quit"): Print "-Goodbye" returnSelf.send (Info)defSend (self, info): URL= Self.apiurl +'key='+ Self.key +'&'+'info='+info re=urllib2.urlopen (URL). Read () re_dict=json.loads (re) text= re_dict['text'] Print '- ', Text self.get ()ifName = ="Main": Chat=Chat () chat.init () Chat.get ( )
Turing man Python demo