Black是facebook提供的一个python formatter工具,为规范、统一代码风格,建议大家统一安装并配置,git地址:https://github.com/psf/black
1、安装Black
pip3 install black
2、查找Black安装路径
which black
3、使用
① 在pycharm集成(推荐)
设置文件监听:进入 PyCharm → Preferences → Tools → File Watchers,添加custom
参考下图依次选择/输入:
Name:Black
File type: Python
Scope:Project Files
Program:第2步which black获取到的路径
Arguments:$FilePath$ -l 500 (这里带上一个参数 -l 500 设置Python每行代码最长500,默认是88,超出88则换行展示,个人觉得不用完全按默认的换行)
Output paths to refresh:$FilePath$
Working directory&