Python Package Cheatsheet
Web 服务:tornado
pip3 install tornado
import sys
import tornado.ioloop
import tornado.web
import json
class MainHandler(tornado.web.RequestHandler):
def post(self):
data = json.loads(self.request.body)
response = {
"status" : "failed",
"message" : ""
}
try:
response["message"] = DoSomething()
except Exception as e:
response["message"] = str(e)
self.write(response)
return
self.write(response)
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
Matplotlib 绘制多条曲线
# importing package
import matplotlib.pyplot as plt
import numpy as np
# create data
x = [1,2,3,4,5]
y = [3,3,3,3,3]
# plot lines
plt.plot(x, y, label = "line 1")
plt.plot(y, x, label = "line 2")
plt.plot(x, np.sin(x), label = "curve 1")
plt.plot(x, np.cos(x), label = "curve 2")
plt.legend()
plt.show()
(施工中)
本文来自博客园,作者:pokpok,转载请注明原文链接:https://www.cnblogs.com/pokpok/p/15850294.html