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 ÿ