国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

腳本之家,腳本語言編程技術(shù)及教程分享平臺!
分類導(dǎo)航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務(wù)器之家 - 腳本之家 - Python - python Autopep8實(shí)現(xiàn)按PEP8風(fēng)格自動排版Python代碼

python Autopep8實(shí)現(xiàn)按PEP8風(fēng)格自動排版Python代碼

2021-09-13 00:02Data_IT_Farmer Python

這篇文章主要介紹了python Autopep8實(shí)現(xiàn)按PEP8風(fēng)格自動排版Python代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

autopep8是一個將python代碼自動排版為pep8風(fēng)格的小工具。它使用pep8工具來決定代碼中的哪部分需要被排版。autopep8可以修復(fù)大部分pep8工具中報告的排版問題。

參考網(wǎng)址:

https://www.python.org/dev/peps/pep-0008/

https://pypi.python.org/pypi/autopep8/

(1)安裝步驟如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
localhost:~ a6$ sudo pip install autopep8
password:
the directory '/users/a6/library/caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. please check the permissions and owner of that directory. if executing pip with sudo, you may want sudo's -h flag.
the directory '/users/a6/library/caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. if executing pip with sudo, you may want sudo's -h flag.
collecting autopep8
collecting pycodestyle>=2.3 (from autopep8)
 downloading pycodestyle-2.3.1-py2.py3-none-any.whl (45kb)
  100% |████████████████████████████████| 51kb 324kb/s
installing collected packages: pycodestyle, autopep8
successfully installed autopep8-1.3.3 pycodestyle-2.3.1
localhost:~ a6$ sudo pip install autopep8
the directory '/users/a6/library/caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. please check the permissions and owner of that directory. if executing pip with sudo, you may want sudo's -h flag.
the directory '/users/a6/library/caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. if executing pip with sudo, you may want sudo's -h flag.
requirement already satisfied: autopep8 in /library/python/2.7/site-packages
requirement already satisfied: pycodestyle>=2.3 in /library/python/2.7/site-packages (from autopep8)

(2)示例代碼:

1)運(yùn)行命令前代碼的排版 (保存在test_autopep8.py)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import math, sys;
 
def example1():
  ####this is a long comment. this should be wrapped to fit within 72 characters.
  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 {'has_key() is deprecated':true}.has_key({'f':2}.has_key(''));
class example3(  object ):
  def __init__  ( self, bar ):
   #comments should have a space after the hash.
   if bar : bar+=1; bar=bar* bar  ; return bar
   else:
          some_string = """
            indentation in multiline strings should not be touched.
only actual code should be reindented.
"""
          return (sys.path, some_string)

2)運(yùn)行命令

?
1
bogon:ab a6$ autopep8 --in-place --aggressive --aggressive test_autopep8.py

3)運(yùn)行命令后代碼的排版

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import math
import sys
def example1():
  # this is a long comment. this should be wrapped to fit within 72
  # characters.
  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
      return bar
    else:
      some_string = """
            indentation in multiline strings should not be touched.
      only actual code should be reindented.
      """
      return (sys.path, some_string)

4)參考網(wǎng)址:
https://github.com/hhatto/autopep8

到此這篇關(guān)于python autopep8實(shí)現(xiàn)按pep8風(fēng)格自動排版python代碼的文章就介紹到這了,更多相關(guān)python autopep8自動排版內(nèi)容請搜索服務(wù)器之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持服務(wù)器之家!

原文鏈接:https://blog.csdn.net/helloxiaozhe/article/details/78954381

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 老司机福利在线视频 | 久久久一二三 | 青青青国产精品一区二区 | 日韩成人在线一区 | 欧美日韩成人在线视频 | 久久av网站 | 特级西西人体444www高清大胆 | 成人在线免费看视频 | 午夜精品影院 | 偷拍一区二区三区 | 国产精品一卡 | 青青草免费在线 | 成人av播放 | 国产精品久久久久免费a∨ 欧美黄色精品 | 96成人爽a毛片一区二区 | 婷婷综合一区 | 久久69精品久久久久久国产越南 | 在线激情网 | 日韩在线一区二区 | 国产精品久久久久免费 | 91精品啪aⅴ在线观看国产 | 国产精品久久久久久福利一牛影视 | 欧美成人精品一区二区三区 | 日本视频一区二区三区 | 国产精品一二三 | 久久久国产一区二区三区 | 91新视频 | 亚洲免费影院 | 欧美成人激情视频 | 免费精品视频 | 日韩在线影院 | 精品少妇一区二区三区日产乱码 | 一区二区欧美在线 | 日本精品视频在线观看 | 亚洲美女久久 | 亚洲精品电影在线观看 | 一区二区亚洲 | 综合二区| 国产高清精品在线 | 亚洲一区二区三区四区的 | 亚洲欧美日韩精品久久亚洲区 |