博客
关于我
python 将函数加到列表中进行调用
阅读量:795 次
发布时间:2023-03-07

本文共 523 字,大约阅读时间需要 1 分钟。

Python 函数调用与列表处理示例

import cv2def toGray(img):    """将图像转换为灰度模式"""    return cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)def testAlgo(img):    """测试算法函数"""    return imgdef detDetect(img):    """检测算法入口"""    return "xx,xxx,xx,xx"if __name__ == '__main__':    # 函数列表存储    functionList = [toGray, testAlgo, detDetect]        # 算法配置    algoConfig = {        '1': functionList    }        # 读取图像    img = cv2.imread(r"D:\LSR\20620160408\1.bmp", cv2.IMREAD_COLOR)        # 调用函数并输出结果    for fun in algoConfig['1']:        print(fun(img))

转载地址:http://rsofk.baihongyu.com/

你可能感兴趣的文章
Python 八大排序算法合集
查看>>
python 关于epoll的学习
查看>>
Python 内存管理
查看>>
Python 内嵌函数:它们有什么用处?
查看>>
Python 内置 sum 函数 vs. for 循环性能
查看>>
python 内置slice的用法
查看>>
Python 内置时间模块
查看>>
python 内部如何实现命名元组?
查看>>
Python 写Android App性能:入门到高级
查看>>
python 写入json数据到数据库
查看>>
Python 出现 TypeError: ‘encoding‘ is an invalid keyword argument for this function 解决方法
查看>>
python 出现 TypeError: ‘list‘ object is not callable 的解决方法
查看>>
python 函数1
查看>>
python 函数学习
查看>>
Python 函数随笔 map()函数,lambda自定义函数
查看>>
Python 分析天气,告诉你中秋应该去哪里
查看>>
python 列表中dict中key排序
查看>>
python 列表函数
查看>>
Python 列表删除相同的元素
查看>>
python 列表生成式
查看>>