摘要: 前台: vue全家桶:单页应用 后台: sanic:http服务器 peewee、peewee_async:mysql数据库模型及驱动 aioredis:redis缓存驱动 sanic_mongo:MongoDB驱动 jinja2:模板引擎(可选) 阅读全文
posted @ 2017-11-20 15:43 hutzerg 阅读(1362) 评论(0) 推荐(0) 编辑
摘要: 1 # settings.py 2 3 import pymysql 4 pymysql.install_as_MySQLdb() 阅读全文
posted @ 2017-11-20 15:26 hutzerg 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 1 class Student(object): 2 __slots__ = ('name', 'age') # 用tuple定义允许绑定的属性名称 阅读全文
posted @ 2017-05-03 11:25 hutzerg 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 1 import urllib 2 3 urllib.urlretrieve(url, filename) 4 5 # url 下载地址 6 # filename 保存的文件名 阅读全文
posted @ 2017-05-02 16:38 hutzerg 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 会输出以下内容: [Errno 2] No such file or directory: '1.txt' 打开文件可能会抛出IOError,我们定义一个msg变量来接受错误信息并打印出来。 以下是常见错误类型 阅读全文
posted @ 2017-02-13 12:10 hutzerg 阅读(146) 评论(0) 推荐(0) 编辑
摘要: class Test(object): x = 11 def __init__(self, _x): self._x = _x print("Test.__init__") @classmethod def class_method(cls): # 类方法 print("class_method") ... 阅读全文
posted @ 2017-02-13 11:40 hutzerg 阅读(156) 评论(0) 推荐(0) 编辑
摘要: strip,strip,lstrip三个函数主要用于移除字串中的满足条件的字符,传入参数是一个字符数组,它们分别表示匹配并去掉右边、两边、左边的字符。 当没有参数传入时,strip()表示去除首尾空格,其它两个函数同理。 code: >>> str = '\tgood to say you,you 阅读全文
posted @ 2017-02-13 11:22 hutzerg 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 1 import SocketServer 2 3 class MyTCPHandler(SocketServer.BaseRequestHandler): 4 def handle(self): 5 while True: 6 self.data = self.request.recv(1024).strip() 7 ... 阅读全文
posted @ 2016-09-14 14:07 hutzerg 阅读(155) 评论(0) 推荐(0) 编辑