autopep8怎么利用Pycharm進(jìn)行配置?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
企業(yè)建站必須是能夠以充分展現(xiàn)企業(yè)形象為主要目的,是企業(yè)文化與產(chǎn)品對外擴(kuò)展宣傳的重要窗口,一個合格的網(wǎng)站不僅僅能為公司帶來巨大的互聯(lián)網(wǎng)上的收集和信息發(fā)布平臺,成都創(chuàng)新互聯(lián)面向各種領(lǐng)域:成都塑料袋等成都網(wǎng)站設(shè)計、成都全網(wǎng)營銷解決方案、網(wǎng)站設(shè)計等建站排名服務(wù)。關(guān)于PEP 8
PEP 8,Style Guide forPythonCode,是Python官方推出編碼約定,主要是為了保證 Python 編碼的風(fēng)格一致,提高代碼的可讀性。
官網(wǎng)地址:https://www.python.org/dev/peps/pep-0008/
關(guān)于Autopep8
Autopep8是自動將Python代碼格式化為符合PEP 8風(fēng)格的工具。它使用pycodestyle工具來確定代碼的哪些部分需要被格式化。Autopep8能夠修復(fù)大部分pycodestyle檢測的格式問題。
github地址:https://github.com/hhatto/autopep8
下載安裝Autopep8
pip install autopep8
使用Autopep8
命令行使用方式如下
$ autopep8 --in-place --aggressive --aggressive <filename>
$ autopep8 --in-place --aggressive --aggressive Student.py
Pycharm配置Autopep8方法
1)具體流程:選擇菜單「File」–>「Settings」–>「Tools」–>「External Tools」–>設(shè)置相關(guān)配置 -> 點擊加號添加工具
填寫如下配置項,點擊「OK」保存
Settings–>Tools–>External Tools 點擊添加按鈕Name:autopep8(可以自定義)
Tools settings:
Programs:autopep8(不能修改)
Parameters:--in-place --aggressive --aggressive $FilePath$
Working directory:$ProjectFileDir$
Advanced Options:在output filters添加:$FILE_PATH$\:$LINE$\:$COLUMN$\:.*
3) 使用autopep8自動格式化你的python代碼
import math def example1(): some_tuple = (1, 2, 3, 'a') some_variable = { 'long': 'Long code lines should be wrapped within 79 characters.', 'other': [math.pi, 100, 200, 300, 9876543210,'This is a long string that goes on'], 'more': { 'inner': 'This whole logical line should be wrapped.',some_tuple: [ 1,20, 300, 40000,500000000,60000000000000000]}} return (some_tuple, some_variable) def example2(): return ('' in {'f': 2}) in {'has_key() is deprecated': True}; class Example3(object): def __init__(self, bar): # Comments should have a space after the hash. if bar: bar += 1 bar = bar * bar else: some_string = """ Indentation in multiline strings should not be touched.Only actual code should be reindented. """
第一種方式:
編寫完代碼后,右鍵選擇「Extern Tools」–>「autopep8」
第二種方式:
選擇菜單「Tool」–>「Extern Tools」–>「autopep8」即可
看完上述內(nèi)容,你們掌握autopep8怎么利用Pycharm進(jìn)行配置的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
當(dāng)前標(biāo)題:autopep8怎么利用Pycharm進(jìn)行配置-創(chuàng)新互聯(lián)
網(wǎng)頁URL:http://muchs.cn/article40/dgioho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、面包屑導(dǎo)航、用戶體驗、移動網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容