Writing response body with BaseHTTPRequestHandler

前端 未结 4 1454
挽巷
挽巷 2021-02-03 21:06

I\'m playing a little with Python 3.2.2 and want to write a simple web server to access some data remotely. This data will be generated by Python so I don\'t want to use the Sim

4条回答
  •  梦毁少年i
    2021-02-03 21:52

    In Python3 string is a different type than that in Python 2.x. Cast it into bytes using either

    self.wfile.write(bytes("Title goes here./html>","utf-8")) 
    

    or

    self.wfile.write("Title goes here.".encode("utf-8"))
    

提交回复
热议问题