博客
关于我
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 gil_Python中GIL的使用详解
查看>>
python glob.glob使用
查看>>
python glob的安装和使用
查看>>
Python google drive API 下载,文件在哪里?
查看>>
Python GPS 模块:读取最新的 GPS 数据
查看>>
python grpc入门
查看>>
python gRPC测试helloworld
查看>>
python list,str的拼接与转换
查看>>
python matplotlib简单使用
查看>>
python os.system
查看>>
Python os.system执行多条语句,os.system的返回值以及与os.popen的区别
查看>>
Python os和sys模块
查看>>
python os文件/目录
查看>>
Python Package 之 Faker(随机姓名、电话)
查看>>
Python Panda TIME 系列重新采样
查看>>
python pandas TimeStamps到夏令时的本地时间字符串
查看>>
Python pandas 数据清洗与数据绘图实战
查看>>
Python Pandas 用顶行替换标题
查看>>
Python pandas 通过 dt 访问器有效地将日期时间转换为时间戳
查看>>