Python代码运行缓慢 - 包含代码 - base64编码

时间:2017-04-05 21:13:47

标签: python base64

我正在尝试base64编码音频flac文件。

有时我的代码会超时。有时它有效。关于我做错什么的任何想法?

import base64
import urllib

def get_flac(uri=None):
   try:
       req = urllib.urlopen(uri)
   except Exception as e:
       print(e)
   return req

def convert_base64(flac_file):
   audio_read = flac_file.read()
   return base64.b64encode(audio_read)

uri = None

try:
   the_file = get_flac('https://host123d1qv.cloudconvert.com/download/~_9IfzT78VnkmVoUPqux_1AQHm1w')
except Exception as e:
   print(e)

try:
   con = convert_base64(the_file)
except Exception as e:
    print(e)

con

0 个答案:

没有答案