如何在Python 3.5中处理“ OverflowError('字符串长于2147483647字节',)”?

时间:2019-04-17 16:38:22

标签: python api

我正在尝试使用cloudconvert API将“ gz”文件转换为“ rar”文件。

我已经尝试过更改

'file':open("C:/Users/nra.pedro/Downloads/"+str(last_downloaded.lastDownloaded()), 'rb'),

代码行:

with open("C:/Users/nra.pedro/Downloads/"+str(last_downloaded.lastDownloaded()), 'rb') as myfile:
[...]
'file' = myfile,

那是我的实际代码:

def gzToRar():
    try: 
        process = api.convert({
            "inputformat": "gz",
            "outputformat": "rar",
            "input": "upload",
            "file": open("C:/Users/nra.pedro/Downloads/"+str(last_downloaded.lastDownloaded()), 'rb')
        })
        process.wait()
        process.download()
        print("Conversão de gz para rar feita com sucesso! \n ANTIGO ARQUIVO: %s \n NOVO ARQUIVO: %s" %(str(last_downloaded.lastDownloaded()),str(last_downloaded.lastDownloaded()).replace(".gz",".rar")))

    except Exception as erro:
        print(erro)

我希望转换文件,但是我收到此错误:

OverflowError('string longer than 2147483647 bytes',)

0 个答案:

没有答案