【问题标题】:RebaseData to read backup filesRebaseData 读取备份文件
【发布时间】:2022-01-25 22:05:48
【问题描述】:

所以我正在尝试读取一个 .bak 文件,从谷歌上搜索,似乎 rebase 是要走的路,但是我不断收到回溯错误

Traceback(最近一次调用最后一次): 文件“C:filepath”,第 1 行,在 从海报.编码导入多部分编码 文件“C:filepath\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poster_init_.py”,第 4 行,在 导入海报.streaminghttp 文件“C:filepath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\poster\streaminghttp.py”,第 58 行 打印“发送:”,repr(值) ^ SyntaxError: 无效语法

重新建立数据代码:

from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2

#Register the streaming http handlers with urllib2

register_openers()

#Use multipart encoding for the input files

datagen, headers = multipart_encode({ 'files[]': open('example.bak', 'rb')})

#Create the request object

request = urllib2.Request('https://www.rebasedata.com/api/v1/convert', datagen, headers)

#Do the request and get the response

#Here the BAK file gets converted to CSV

response = urllib2.urlopen(request)

#Check if an error came back

if response.info().getheader('Content-Type') == 'application/json':
    print response.read()
    sys.exit(1)

#Write the response to /tmp/output.zip

with open('/tmp/output.zip', 'wb') as local_file:
    local_file.write(response.read())

print 'Conversion result successfully written to /tmp/output.zip!'

我如何真正让这个脚本运行?谢谢。 注意我用“filepath”替换了我的原始文件路径

【问题讨论】:

    标签: python backup rebase


    【解决方案1】:

    poster 模块似乎正在尝试使用 Python 2 类型的 print "x" 语法,而不是 Python 3 的 print("x") 语法。

    您可能尝试使用错误版本的poster。有一个模块叫poster3,不妨试试看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-25
      • 1970-01-01
      • 2015-08-21
      • 2013-06-12
      • 1970-01-01
      • 1970-01-01
      • 2018-09-03
      • 1970-01-01
      相关资源
      最近更新 更多