Python 3.6.1通过POST以字节的形式发送和接收图像

Python 3.6.1通过POST以字节的形式发送和接收图像,python,python-3.x,post,byte,urllib,Python,Python 3.x,Post,Byte,Urllib,我试图通过Post发送和接收png图像 我正试图这样发送: with bytes as <class 'bytes'> datatype def call(videoid, count, bytes): print(videoid) opener = request.build_opener() param = {'videoid' : '{0}'.format(videoid), 'count':'{0}'.format(count), 'bytes':'{0}'

我试图通过Post发送和接收png图像

我正试图这样发送:

 with bytes as <class 'bytes'> datatype

 def call(videoid, count, bytes):
  print(videoid)
  opener = request.build_opener()
  param = {'videoid' : '{0}'.format(videoid), 'count':'{0}'.format(count), 'bytes':'{0}'.format(bytes)}
  data=json.dumps(param).encode('utf8')
  req = request.Request(os.environ['ImageProcessURL'], data=data, headers={'Content-Type': 'application/json'})
  response = opener.open(req)
postreqdata = json.loads(open(os.environ['req']).read())
videoid = postreqdata['videoid']
count = postreqdata['count']
bytesstr = postreqdata['bytes']
但这里字节现在是一个字符串。 如何将其转换回原始字节类型