我不能用d打印一些东西给控制台

2024-09-28 03:13:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我无法在定义的函数中打印任何内容。解决办法是什么

import cv2
def ResimFarkBul(Resim1,Resim2):
    Resim2 = cv2.resize(Resim2,(Resim1.shape[1],Resim1.shape[0]))
    Fark_Resim = cv2.absdiff(Resim1,Resim2)
    Fark_Sayı = cv2.countNonZero(Fark_Resim)
    print(Fark_Sayı)

任何帮助都将不胜感激


Tags: 函数import内容定义defcv2sayshape
1条回答
网友
1楼 · 发布于 2024-09-28 03:13:32

创建函数后忘记调用它:

你需要的只是简单的称呼它

 ResimFarkBul(arg1, arg2)

您创建了一个带有参数的函数,这意味着当您调用它时,需要为它提供参数

示例:

    #create function
    def print_something(arg1, arg2):
       print("arg1 =>", arg1)
       print("arg2 =>", arg2)

    # now you need to call it
    print_something("spam", "eggs") # this will print "arg1 => spam", "arg2 => eggs"
   # if you call print_something() you ll get Error because you didnt give any arguments and declared the functions with arguments

相关问题 更多 >

    热门问题