-1
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"

我应该怎么办 ?

4

1 回答 1

-1

您的情况示例:

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

引发相同错误的结果: TypeError: can only concatenate str (not "tuple") to str

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

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

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

于 2021-09-02T10:28:14.203 回答