Turing man Python demo

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.