object type <class ‘str‘> cannot be passed to c code

Python Cryp## to报错解决:object type <class ‘str‘> cannot be passed to c code

主要是我获取key密匙的时候没有进行解码也就是encode=’utf-8‘
代码如下

    with open('../second_m3u8.m3u8', 'r', encoding='utf-8') as f:
        a = f.readlines()[5]
        a.strip()
        a = re.findall(r'URI="(.*?)"', a)[0]
        key = requests.get(a).text
        key = key.encode('utf-8')#!!!!!!!!!!!!!!!!!!!!!!!!
        return key

解决方案

对获得的可以进行编码

 key = key.encode('utf-8')

你可能感兴趣的:(python,大数据,数据挖掘,bug)