- 正则 :re
- 测试
- 日志:logging
- 打印错误信息:sys.exc_info()
配置Nginx
1 | server { |
如nginx报错
1 | #nging/error.log |
如Nginx 报404
1 | 2018/11/08 08:41:49 [error] 13474#13474: *1 "/home/abc/bbs/index.php" is not found (2: No such file or directory), client: 106.120.83.206, server:, request: "GET / HTTP/1.1", host: "" |
需要检查文件权限及nginx进程用户是否有权限访问该目录
查看代码文件所属目录是否同一个用户/有访问权限
如果你使用vagrant 环境,vagrant 共享目录默认用户是vagrant 可以通过vagrant配置文件修改
1 | config.vm.synced_folder "./", "/vagrant",create:true, :owner=>"www", :group=>"www",:mount_options=>["dmode=775","fmode=775"] |
修改nginx 进程使用用户
1 | >>> vim /usr/local/nginx/conf/nginx.conf |
如你数据库使用阿里云/腾讯云,可能会出现报错
页面报错信息: discuz Table ‘xxxxx.forum_post’ doesn’t exist
数据库报错信息: 报错:#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
可按以下sql手动创建表
1 | CREATE TABLE IF NOT EXISTS `pre_forum_post` ( |
修改论坛首页头部
文件位于:/template/default/commom/header.htm
example
1 | class MyClass: |
继承
1 | class DerivedClassName(BaseClassName): |
1 | # 函数 isinstance()用于检查实例类型 |
public: name
protect : _name
private: __name
迭代器:
1 | class Reverse: |
生成器
1 | def reverse(data): |
Python模块
引入模块
1 | # 方式一 |
以脚本方式运行模块,name 被设置为 “main“
1 | >>> python module.py |
模块搜索路径
`
from sound.effects import echo
echo.echofilter(input, output, delay=0.7, atten=4)
1 | aiohttp.client_exceptions.ServerDisconnectedError |
1 | import async_timeout |
循环技巧:
1 | # 列表循环技巧: |
推导式
1 | # 列表推导式 |
操作符:
and, or : 参数从左向右解析,一旦结果可以确定就停止
1 | string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' |
in, not in
计算图片MD5,如果MD5一致,判断为同一张图片
1 | def calMD5(url): |
异步HTTP库aiohttp: https://hubertroy.gitbooks.io/aiohttp-chinese-documentation/content/
1 | sslcontext = ssl.create_default_context(cafile='/test.crt') |
协程:https://docs.python.org/3/library/asyncio-task.html
1 | sema = asyncio.Semaphore(2) |