Py学习  »  Python

Python:无法在第一个函数的结果之后移动到第二个函数

Christopher Pisano • 5 年前 • 1458 次点击  

项目目标: 搜索定义的yamlfile( scan_dcn.yaml function_search_search_key() function_search_event_type() 功能。

输入文件-scan_dcn.yaml:

search_dict:
    [
        {search_key: ["Failed to Process the file"],
        event_type: "evttyp_repl_dcn_error",
        event_description: "Failure to process DCN file",
        priority: 50,
        scan_interval: 1,
        remove_dups: True,
        category: "dcn",
        context_begin: 0,
        context_end: 1,
        reportable: False,
        offset: 0
        },

我的程序将返回 函数搜索键() 但不会继续

是否需要在每个函数中返回一个值才能继续?

Python源代码

yamlfile = open('scan_dcn.yaml', 'r')


def function_search_search_key():
    search_search_key = ['{search_key:']
    for line in yamlfile.readlines():
        for word in search_search_key:
            if word in line:
                print(line)


def function_search_event_type():
    search_event_type = ['event_type:']
    for line in yamlfile.readlines():
        for word in search_event_type:
            if word in line:
                print(line)


def main():
    function_search_search_key()
    function_search_event_type()


main()
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/53239
 
1458 次点击  
文章 [ 3 ]  |  最新文章 5 年前