• <legend id='mAYte'><style id='mAYte'><dir id='mAYte'><q id='mAYte'></q></dir></style></legend>

    <small id='mAYte'></small><noframes id='mAYte'>

    <i id='mAYte'><tr id='mAYte'><dt id='mAYte'><q id='mAYte'><span id='mAYte'><b id='mAYte'><form id='mAYte'><ins id='mAYte'></ins><ul id='mAYte'></ul><sub id='mAYte'></sub></form><legend id='mAYte'></legend><bdo id='mAYte'><pre id='mAYte'><center id='mAYte'></center></pre></bdo></b><th id='mAYte'></th></span></q></dt></tr></i><div id='mAYte'><tfoot id='mAYte'></tfoot><dl id='mAYte'><fieldset id='mAYte'></fieldset></dl></div>

        • <bdo id='mAYte'></bdo><ul id='mAYte'></ul>

        <tfoot id='mAYte'></tfoot>
      1. 如何在运行Python代码时从Pylint获得Report+分数?

        How to get report + score from Pylint when run Python code?(如何在运行Python代码时从Pylint获得Report+分数?)

          1. <i id='wIFv4'><tr id='wIFv4'><dt id='wIFv4'><q id='wIFv4'><span id='wIFv4'><b id='wIFv4'><form id='wIFv4'><ins id='wIFv4'></ins><ul id='wIFv4'></ul><sub id='wIFv4'></sub></form><legend id='wIFv4'></legend><bdo id='wIFv4'><pre id='wIFv4'><center id='wIFv4'></center></pre></bdo></b><th id='wIFv4'></th></span></q></dt></tr></i><div id='wIFv4'><tfoot id='wIFv4'></tfoot><dl id='wIFv4'><fieldset id='wIFv4'></fieldset></dl></div>

              1. <tfoot id='wIFv4'></tfoot>
                <legend id='wIFv4'><style id='wIFv4'><dir id='wIFv4'><q id='wIFv4'></q></dir></style></legend>

                <small id='wIFv4'></small><noframes id='wIFv4'>

                  <bdo id='wIFv4'></bdo><ul id='wIFv4'></ul>
                    <tbody id='wIFv4'></tbody>
                  本文介绍了如何在运行Python代码时从Pylint获得Report+分数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  直接从Python代码运行pylint时,似乎无法获得任何返回值。从命令行运行它会生成一个很好的报告,底部会显示汇总分数。

                  我尝试将"run"的返回值放入一个变量,并将其放入"Reports"字段-但它看起来像某个默认模板。

                  这是我拥有的:

                  from io import StringIO
                  from pylint.reporters import text
                  from pylint.lint import Run
                  
                  
                  def main():
                      print("I will verify you build!")
                      pylint_opts = ['--rcfile=pylintrc.txt', '--reports=n', 'utilities']
                      pylint_output = StringIO()
                      reporter = text.TextReporter(pylint_output)
                      Run(pylint_opts, reporter=reporter, do_exit=False)
                      print(pylint_output.read())
                  
                  
                  if __name__ == '__main__':
                      main()
                  

                  我希望这里会有一些报告,但我得到的都是: " 我将验证您的版本!

                  进程已完成,退出代码为0 "

                  推荐答案

                  我调查了pylint问题。我们最终保留了当前行为,因为您的代码只需稍作调整即可工作:

                  def main():
                      print("I will verify you build!")
                      pylint_opts = ['--rcfile=pylintrc.txt', '--reports=n', 'utilities']
                      pylint_output = StringIO()
                      reporter = text.TextReporter(pylint_output)
                      Run(pylint_opts, reporter=reporter, do_exit=False)
                      print(pylint_output.getvalue())
                  

                  StringIO是不隐藏流位置的流。Pylint正确写入pylint_output,但将光标留在流的末尾。pylint_output.read()仅从游标开始读取。

                  您可以先调用pylint_output.seek(0)重置流位置,然后再调用pylint_output.read()。或者,如上面的代码挡路所示,StringIO提供了一个方法getvalue,该方法将返回缓冲区的全部内容,而不考虑光标的位置。

                  Pylint文档将使用此示例进行更新,因此感谢您提出此问题。

                  这篇关于如何在运行Python代码时从Pylint获得Report+分数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                  How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                  Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                  How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                  Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                  How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                    <legend id='y5pRl'><style id='y5pRl'><dir id='y5pRl'><q id='y5pRl'></q></dir></style></legend>

                        <tbody id='y5pRl'></tbody>
                      <i id='y5pRl'><tr id='y5pRl'><dt id='y5pRl'><q id='y5pRl'><span id='y5pRl'><b id='y5pRl'><form id='y5pRl'><ins id='y5pRl'></ins><ul id='y5pRl'></ul><sub id='y5pRl'></sub></form><legend id='y5pRl'></legend><bdo id='y5pRl'><pre id='y5pRl'><center id='y5pRl'></center></pre></bdo></b><th id='y5pRl'></th></span></q></dt></tr></i><div id='y5pRl'><tfoot id='y5pRl'></tfoot><dl id='y5pRl'><fieldset id='y5pRl'></fieldset></dl></div>

                      1. <tfoot id='y5pRl'></tfoot>
                      2. <small id='y5pRl'></small><noframes id='y5pRl'>

                            <bdo id='y5pRl'></bdo><ul id='y5pRl'></ul>