社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

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

Christopher Pisano • 5 年前 • 1334 次点击  

项目目标: 搜索定义的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
 
1334 次点击  
文章 [ 3 ]  |  最新文章 5 年前