TypeError: a bytes-like object is required, not ‘str‘

出现问题的原因可能是因为在python2中是str类型,而在python3中是bytes类型,所以解决办法就是将str类型转换为bytes类型:

  1. 通过str.encode()方法可以将str类型转换为bytes类型
  2. 通过bytes.decode()方法可以将bytes类型转化为str类型

你可能感兴趣的:(python)