二进制文件IO在蟒蛇

二进制文件IO在蟒蛇

本文介绍了二进制文件IO在蟒蛇,从哪里开始?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为一个自学成才的业余爱好者蟒蛇,我将如何去学习使用标准格式导入和导出二进制文件?

As a self-taught python hobbyist, how would I go about learning to import and export binary files using standard formats?

我想实现一个脚本,它的ePub电子书(XHTML + CSS中的zip),并为了让亚马逊的Kindle来阅读格式,将其转换为一个Mobipocket的(Palmdoc)(作为一个更大的项目的一部分那我的工作)。

I'd like to implement a script that takes ePub ebooks (XHTML + CSS in a zip) and converts it to a mobipocket (Palmdoc) format in order to allow the Amazon Kindle to read it (as part of a larger project that I'm working on).

有已经是管理的电子书图书馆一个真棒开源项目:。我想试试我自己实施本作为学习/自学练习。我开始看他们的python来源$ C ​​$ C 并意识到,我不知道是怎么回事。当然,作为自学成才在什么大危险,就是不知道你不知道的东西。

There is already an awesome open-source project for managing ebook libraries : Calibre. I wanted to try implementing this on my own as a learning/self-teaching exercise. I started looking at their python source code and realized that I have no idea what is going on. Of course, the big danger in being self-taught at anything is not knowing what you don't know.

在这种情况下,我知道,我不知道太多关于这些二进制文件,如何与他们在python code工作(的?)。但是我想我可能错过了很多的知识对一般的二进制文件,我想一些帮助了解如何与他们合作。 。谢谢!

In this case, I know that I don't know much about these binary files and how to work with them in python code (struct?). But I think I'm probably missing a lot of knowledge about binary files in general and I'd like some help understanding how to work with them. Here is a detailed overview of the mobi/palmdoc headers. Thanks!

编辑:毫无疑问,好点!你对如何获得二进制文件工作的基本知识什么秘诀? Python特定的将是有益的,但​​其他方法也可能是有用的。

No question, good point! Do you have any tips on how to gain a basic knowledge of working with binary files? Python-specific would be helpful but other approaches could also be useful.

TOM:编辑成问题,添加片头/更好的标题

TOM:Edited as question, added intro / better title

推荐答案

您或许应该开始与模块,正如你指出你的问题,当然,打开该文件为二进制。

You should probably start with the struct module, as you pointed to in your question, and of course, open the file as a binary.

基本上你刚开始在文件的开头和一块采摘它拆开一块。这是一个麻烦,但不是一个巨大的问题。如果文件COM pressed或加密,事情可能会变得更加困难。如果你有,你知道,所以你不猜测所有的时间,内容的文件开始,这非常有用。

Basically you just start at the beginning of the file and pick it apart piece by piece. It's a hassle, but not a huge problem. If the files are compressed or encrypted, things can get more difficult. It's helpful if you start with a file that you know the contents of so you're not guessing all the time.

试用了一下,也许你会发展更具体的问题。

Try it a bit, and maybe you'll evolve more specific questions.

这篇关于二进制文件IO在蟒蛇,从哪里开始?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 08:31