按PEP8风格自动排版Python代码
作者:互联网
Autopep8是一个将Python代码自动排版为PEP8风格的小工具。它使用pep8工具来决定代码中的哪部分需要被排版。Autopep8可以修复大部分pep8工具中报告的排版问题。
安装步骤如下:
![](https://upload-images.jianshu.io/upload_images/13406307-4f6e2c34223aa485.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
示例代码:
运行命令前代码的排版 (保存在test_autopep8.py)
![](https://upload-images.jianshu.io/upload_images/13406307-b0b65cebfbbb32f2.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
运行命令
autopep8 --in-place --aggressive --aggressive test_autopep8.py
运行命令后代码的排版
![](https://upload-images.jianshu.io/upload_images/13406307-3dd62172ea50b59a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
标签:autopep8,Python,代码,py,PEP8,aggressive,排版 来源: https://www.cnblogs.com/Pythonmiss/p/10719449.html