只能将 str(不是 "tuple")连接到 str

can only concatenate str (not "tuple") to str

def chek_stationary(x):
    result=adfuller(x)
    label=['ADF statestic test','p value','num of legs','num of observation']
    for value,label in zip(result,label):
        print(label + ":" + result)
    if result[1] <= 0.05 :
        print ('there is evedincee null hypothesis')
        print('which means there is no root here ')
        print ('and its  stationary ')
    else :
        print ('there isnot evedence and there is root and its nun stationrary')

每当我尝试这个函数时,我都会收到这个错误:"can only concatenate str (not "tuple") to str"

我该怎么办?

您的情况示例:

str_var = 'aaa'
tuple_var = ('b','B')
print(str_var  + ":" +  tuple_var)

抛出相同错误的结果: 类型错误:只能将 str(不是“元组”)连接到 str

修复: - 只需在之前添加 str() 函数。

str_var = 'aaa'
tuple_var = ('b','B')
print(str_var  + ":" +  str(tuple_var))

没有错误的结果: aaa:('b', 'B')