這個(gè)錯(cuò)誤是因?yàn)槟褂昧诉壿嬤\(yùn)算符&來執(zhí)行按位與(bitwise and)運(yùn)算,而它不適用于浮點(diǎn)數(shù)類型的輸入數(shù)據(jù)。
要比較兩個(gè)浮點(diǎn)數(shù)是否在一個(gè)范圍內(nèi),您可以使用邏輯運(yùn)算符and,或者使用numpy庫中的logical_and函數(shù)。具體地,您可以按照以下方式更改代碼:
1.使用邏輯運(yùn)算符and來替代&文章來源:http://www.zghlxwxcb.cn/news/detail-626993.html
if true20201[i][j]>=50.0 and true20201[i][j]<=60.0: # 使用邏輯運(yùn)算符and,比較浮點(diǎn)數(shù)
2.使用numpy庫中的logical_and函數(shù)來執(zhí)行按位與運(yùn)算。文章來源地址http://www.zghlxwxcb.cn/news/detail-626993.html
if np.logical_and(true20201[i][j]>=50.0, true20201[i][j]<=60.0): # 使用logical_and函數(shù)執(zhí)行按位與運(yùn)算
到了這里,關(guān)于TypeError: ufunc ‘bitwise_and‘ not supported for the input types, and the inputs could not be safely的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!