解决“AttributeError: ‘str‘ object has no attribute ‘decode‘”问题

在运行Python代码时遇到AttributeError,提示'str'对象没有'decode'属性。问题分析表明这是由于尝试对已经为Unicode编码的字符串调用decode方法导致的。解决方法是无需修改代码,直接避免对字符串使用decode操作,从而解决问题。
摘要由CSDN通过智能技术生成

问题描述

在跑代码的时候出现报错提示

Traceback (most recent call last):
  File "multi_detect_Nerual.py", line 4, in <module>
    import BiLSTM.bilstm_speech_seg_predict as nerual_seg
  File "/home/xxx/xxx/xxx/BiLSTM/bilstm_speech_seg_predict.py", line 23, in <module>
    model.load_weights(h5_model_file)
  File "/home/xxx/anaconda3/envs/xxx/lib/python3.7/site-packages/keras/engine/network.py", line 1166, in load_weights
    f, self.layers, reshape=reshape)
  File "/home/xxx/anaconda3/envs/xxx/lib/python3.7/site-packages/keras/engine/saving.py", line 1004, in load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'

问题分析

该报错意思是:属性错误:'str'对象没有'decode'属性

解决方法

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值