Communication between two python scripts

前端 未结 3 2055
执笔经年
执笔经年 2020-12-03 03:18

a methodology question:

I have a \"main\" python script which runs on an infinite loop on my system, and I want to send information to it (a json data string for exa

3条回答
  •  庸人自扰
    2020-12-03 03:57

    In case you are interested in implementing the client script that Mike presented in Python 3.x, you will quickly find that there is no httplib available. Fortunately, the same thing is done with the library http.client.

    Otherwise it is the same:

    import http.client
    c = http.client.HTTPConnection('localhost', 8080)
    c.request('POST', '/process', '{}')
    doc = c.getresponse().read()
    print(doc)
    

    Though this is old I would figure I would post this since I had a similar question today but using a server.

提交回复
热议问题