<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Autopep8PEP8 風(fēng)格代碼排版工具

          聯(lián)合創(chuàng)作 · 2023-10-02 02:58

          Autopep8 是一個(gè)將 Python 代碼自動(dòng)排版為 PEP8 風(fēng)格的工具。它使用 pycodestyle 程序來(lái)確定代碼的哪些部分需要排版。Autopep8 可以修復(fù)大部分 pycodestyle 報(bào)告的排版問(wèn)題。

          示例

          排版前:

          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)

          排版后:

          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)
          瀏覽 21
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  无码看电影 | 国产人兽网站 | 色先锋资源一区二区 | 在线播放中文字幕 | 热99在线观看 |