[%(asctime)-15s] [%(levelname)s] - %(message)s (%(filename)s:%(lineno)s) 得到的结果是
[2018-11-02 09:56:14] [INFO] - start flask app (manage.py:21)
[2018-11-02 09:56:14] [WARNING] - * Debugger is active! (_internal.py:88)
[2018-11-02 09:56:14] [INFO] - * Debugger PIN: 323-630-998 (_internal.py:88)
加上右对齐(左对齐一样), [%(asctime)-15s] [%(levelname)8s] - %(message)s (%(filename)s:%(lineno)s) 得到的结果是
[2018-11-02 09:58:30] [ INFO] - start flask app (manage.py:21)
[2018-11-02 09:58:30] [ WARNING] - * Debugger is active! (_internal.py:88)
[2018-11-02 09:58:30] [ INFO] - * Debugger PIN: 323-630-998 (_internal.py:88)
而我想要得是
[2018-11-02 09:58:30] [INFO] - start flask app (manage.py:21)
[2018-11-02 09:58:30] [WARNING] - * Debugger is active! (_internal.py:88)
[2018-11-02 09:58:30] [INFO] - * Debugger PIN: 323-630-998 (_internal.py:88)
1
tinyproxy 2018-11-05 16:10:32 +08:00
```python
import logging logging.basicConfig(level=logging.DEBUG, format="%(levelname)s %(message)s") logging.debug('it works') # DEBUG it works logging.addLevelName(logging.DEBUG, '[my debug name]{BLANK PADDINGS}') logging.debug('it works') # [my debug name]{BLANK PADDINGS} it works ``` |
2
chinawrj 2018-11-05 16:20:31 +08:00 1
你要的是"]"之后的制表符\t
|
4
lolizeppelin 2018-11-08 16:22:29 +08:00 via Android
最好不要用制表符 自己算长度呗
类似的代码可以看 prettytable |
5
hanssx OP @lolizeppelin 为何不要用制表符呢?能详细说下吗
|