简体   繁体   English

使用Pycharm,一旦运行代码,我就不会得到任何输出,只是进程以退出代码0完成

[英]Using Pycharm I don't get any output once code is run, just Process finished with exit code 0

So pretty much, I have a directory that contains many of 2 types of text files, a bunch of files that begin with "summary_" and a bunch of files that begin with "log". 差不多,我有一个目录,其中包含2种类型的文本文件,一堆以“ summary_”开头的文件和一堆以“ log”开头的文件。 All these text are in the same directory. 所有这些文本都在同一目录中。 For now I don't care about the "log" text files, I only care about the files that start with "summary". 现在,我不关心“日志”文本文件,只关心以“摘要”开头的文件。

Each "summary" file contains either 7 lines of text or 14 lines of text. 每个“摘要”文件包含7行文本或14行文本。 At the end of each line it will say either PASS or FAIL depending on the test result. 在每一行的末尾,将根据测试结果显示“通过”或“失败”。 For the test result to be passing all 7 or 14 lines have to say "PASS" at the end. 为了使测试结果通过所有7或14行,最后必须说“ PASS”。 If one of those lines have just one "FAIL" in it, The test has failed. 如果其中一行仅包含一个“ FAIL”,则测试失败。 I want to count the number of passes and failures. 我想计算通过和失败的次数。

import os
import glob

def pass_or_fail_counter():

    pass_count = 0
    fail_count = 0

    os.chdir("/home/dario/Documents/Log_Test")
    print("Working directory is ") + os.getcwd()
    data = open('*.txt').read()
    count = data.count('PASS')

    if count == 7 or 14:
        pass_count = pass_count + 1
    else:
        fail_count = fail_count + 1
    print(pass_count)
    print(fail_count)
    f.close()

pass_or_fail_counter()

I don't know about within Pycharm, but the following seems to work without it: 我不了解Pycharm内部的内容,但以下内容似乎可以解决此问题:

import os
import glob

def pass_or_fail_counter(logdir):
    pass_count, fail_count = 0, 0

    for filename in glob.iglob(os.path.join(logdir, '*.txt')):
        with open(filename, 'rt') as file:
            lines = file.read().splitlines()

        if len(lines) in {7, 14}:  # right length?
            if "PASS" in lines[-1]:  # check last line for result
                pass_count += 1
            else:
                fail_count += 1

    print(pass_count, fail_count)

pass_or_fail_counter("/home/dario/Documents/Log_Test")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我在 Pycharm 中运行此代码时,我没有得到任何输出,它只是显示---进程以退出代码 0 完成。请帮我解决这个问题 - when I run this code in Pycharm i didn't get any outputs simply it shows---— process finished with exit code 0. please help me with this issue 每当我尝试在输入中输入内容时,它只会说“进程以退出代码0完成”(使用pycharm) - Whenever I try to enter something in an input, it just says “process finished with exit code 0” (Using pycharm) PyCharm:进程已完成,退出代码为 0 - PyCharm: Process finished with exit code 0 进程以退出代码 0 结束,但我看不到任何 output - Process finished with exit code 0 but I cannot see any output PyCharm/Python。 代码不运行。 立即收到“Getting Process finished with exit code 0” - PyCharm/Python. Code doesn't run. Immediately receiving "Getting Process finished with exit code 0" Pycharm。 '进程以退出代码 0 结束'。 打印()中没有 output - Pycharm. 'Process finished with exit code 0' . No output in print() PyCharm中的OpenCV代码:进程结束,退出代码为0 - OpenCV code in PyCharm: Process finished with exit code 0 进程以退出代码 0 结束但没有输出 - Process finished with exit code 0 but no output python:使用 PyCharm 和 PyQt5 时,进程以退出代码 1 结束 - python: Process finished with exit code 1 when using PyCharm and PyQt5 “进程以退出代码 -2147483645 完成” Pycharm - "Process finished with exit code -2147483645" Pycharm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM