我可以让python中的pep8解析字符串而不是文件吗?

时间:2014-06-19 18:51:10

标签: python format pep8 pep8-checker

import pep8

s = """
def a:
    pass

def b:
   pass

"""

pep8.StyleGuide().is_such_method_exists_for_string_?(s)

//然后,把它作为列表输出?

1 个答案:

答案 0 :(得分:1)

import pep8

lines = """
def a:
    pass

def b:
   pass
"""

checker = pep8.Checker(
    lines=lines.strip().splitlines(),
    filename=None,
    show_source=True
)
result = checker.check_all()