TypeError:需要一个类似字节的对象,而不是Python3.6.8

我是python的新手...最近我已迁移到Py 3.6.8。这段代码在Python 2.7中正常工作:

#!/usr/bin/env python
from __future__ import print_function
import json
import sys
import os
import re
import subprocess
import datetime
from glob import glob
import boto3

class VariableCollector:
  def getall(self):
    collected_vars = {}
    for name in dir(self):
      #name = name.decode()
      if name.startswith("get_"):
        debug("VariableCollector - Calling: %s" % (name))
        method = getattr(self,name)
        collected_vars[name] = method()
        collected_vars[name + ":no_quotes"] = collected_vars[name].replace("'","")

        debug("Function: [%s] Value: [%s]" % ( name,collected_vars[name] ))
    return collected_vars

升级到3.6.8后,我得到了:

  File "./process.py",line 21,in getall
    collected_vars[name + ":no_quotes"] = collected_vars[name].replace("'","")
TypeError: a bytes-like object is required,not 'str'
allcap 回答:TypeError:需要一个类似字节的对象,而不是Python3.6.8

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2865982.html

大家都在问