使用pycodestyle和autopep8幫助Python程式碼進行格式化

pycodestyle

會提式出程式碼哪個部分需要修正

$ pycodesytle mystery.py
mystery.py:18:1: E302 expected 2 blank lines, found 1
mystery.py:22:19: E231 missing whitespace after ‘:’

autopep8

會自動幫忙修正程式碼

# Overwrites file.py for PEP8 compliance
$ autopep8 --in-place --aggressive --aggressive file.py

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store