import sys import click from flask_migrate import Migrate, upgrade from app import create_app, db from app.models import User, Follow, Role, Permission, Post, Comment
@app.cli.command() @click.option('--length', default=25, help='Number of functions to include in the profiler report.') @click.option('--profile-dir', default=None, help='Directory where profiler data files are saved.') defprofile(length, profile_dir): """Start the application under the code profiler.""" from werkzeug.contrib.profiler import ProfilerMiddleware app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length], profile_dir=profile_dir) app.run()
Commands: deploy Run deployment tasks. profile Start the application under the code... test Run the unit tests.#新添加的内容
python flasky.py test
1 2 3 4 5 6 7
(microvenv) [root@iz2ze8rern8nx1sglo8ub1z microblog]# python flasky.py test te 大专栏学习日记-2019529st_password_setter (test_user_model.UserModelTestCase) ... ok
---------------------------------------------------------------------- Ran 1 test in0.447s
pi = 3.1415926 print('{:.2f}'.format(pi))#保留两位小数3.14
三层{}可以转义
1
print('{{{0:.2f}}}'.format(pi))#{3.14}
Python多进程
进程创建
unix下使用fork方式创建子进程
1 2 3 4
Process 24896 start ... This is Father process,And Its child pid is24897 This is child process and my pid is24897,my father process is1 #子进程fork的结果总是0,可以用来作为区分父子进程的标志