about how Python handles Word docs doc docx, you can focus on the Python-docx and python-docx2txt two projects, python-docx more complex and appropriate to create documents, Python-docx2txt makes it easy to convert documents to txt:
https://python-docx.readthedocs.org/en/latest/
Https://github.com/python-openxml/python-docx
In addition DOC file itself is a compressed file, the actual document content is XML structure, you can use unzip decompression:
# Unzip Test.docxArchive:test.docxInflating:
#-*-CODING=GBK-*-import zipfiledef UnZip (Path, patht): #path for the file path that needs to be decompressed, patht for the extracted target directory f = zipfile.ZipFile (path, ' R ') print "Start extracting files ..." For file in F.namelist (): print "Extracting file:%s to%s"% (file, patht) F.extract (file, patht)Under Windows Python uses the above code to extract the zip file, found that the decompression will be the last modification time of the file to extract the time, although the use of
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Using system. Io. packaging;
Using system. IO;
Using utilities. Io. extensionmethods;
Using utilities. datatypes. extensionmethods;
Namespace utilities. fileformats. Zip{/// /// Helper class for dealing with zip files/// Public class zipfile: idisposable{# Region Constructor
/// /// Constructor/// /// /// Public zipfile
This article mainly introduces the example of using the memory zipfile object to package files in the memory in python. For more information, see the following code:
Import zipfileImport StringIO
Class InMemoryZip (object ):Def _ init _ (self ):# Create the in-memory file-like objectSelf. in_memory_zip = StringIO. StringIO ()
Def append (self, filename_in_zip, file_contents ):'''Appends a file with name filename_in_zip and contentsFile_contents to th
Copy Code code as follows:
Import ZipFile
Import Stringio
Class Inmemoryzip (object):def __init__ (self):# Create the In-memory File-like objectSelf.in_memory_zip = Stringio.stringio ()
def append (self, filename_in_zip, file_contents):' Appends a file with name Filename_in_zip and contents ofFile_contents to the in-memory zip. '# Get a handle to the ' in-memory zip in append modeZF = ZipFile.
The code is as follows:
Import ZipFileImport Stringio
Class Inmemoryzip (object):def __init__ (self):# Create the In-memory File-like objectSelf.in_memory_zip = Stringio.stringio ()
def append (self, filename_in_zip, file_contents):"Appends a file with name Filename_in_zip and contents ofFile_contents to the in-memory zip. "# Get A handle to the In-memory zip in append modeZF = ZipFile. ZipFile (Self.in_me
Use the Java.util.zip.ZipFile class to extract the files.
Can extract Zip,jar,war, but cannot extract RAR file.
Import Java.io.BufferedInputStream;
Import Java.io.BufferedOutputStream;
Import Java.io.File;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import java.util.Enumeration;
Import Java.util.zip.ZipEntry;
Import Java.util.zip.ZipFile;
public class UnZip {static final int BUFFER = 1024;
public void unzip (file Unzipdir, file Zip) throws IOException {if (!zip.exists ()
about.
Take FileInputStream as the representative, writ's reading, is not more than 255, big is to make negative, this I also really can't push out, oh, right, pay attention to different encoding format, such as a Chinese character, read up the number of bytes may be 2, may be 3 bytes. Read reads a bit, the bits that are read are displayed in decimal, and can be converted to characters for easy viewing.
16-bit stream eight-bit streams, outputstreamwriter, base class like Filewrit, these are n
When doing a file operation, the general steps are as follows:
Read operation: To target file new an input stream-> read data-> manipulate data
Write: New to target file a output stream-> call write method write data
Understanding the Java
To operate on a ZIP file, the following three classes are used primarily:1, ZipFile. Represents a class associated with a zip file operation. You can use this class to create a zip file or to open a zip file.2, Ziparchive. Represents a Zip document instance through which you can create a zip document directly from a Stream object. The ZipFile class operates primarily on disk files, while ziparchive represen
[Java iO] _ compressing stream notes
Objectives of this chapter:Measure the test taker's understanding about the main functions of the compressed stream.Understand three compression formats supported by Java IoUnderstanding the functions of zipoutputstream, zipfile, and zipinputstream
3. Details
Zipentry
ZipoutputstreamCompresses a file or folder into a zip file.
Instance code:
Import Java. io. file; import Java. io. fileinputstream; import Java. io
Get started with the java.util.zip package in extracting filesGet started with the java.util.zip package in extracting filesI accidentally clicked some of the source code in the java.util.zip package. Knowing the scope of use is for our dailyFile compression and decompression. Write some common compressed files (compression of a single file and multiple files), decompress files (decompress a single file and folder)Demo.Package com.clark.zip;Import java. io. File;Import java. io. FileInputStream;
store (no compression) and deflate Compression Method(Store (non-compressed) and deflate compression methods are supported-not quite clear)
Create or extract files from split ZIP files (ex: z01, z02,....zip)(Create and Extract files for multipart ZIP files)
Supports Unicode file names(Supports Unicode encoding file names)
Progress Monitor(Progress Monitoring)
From the main features above, we can see that zip4j is very powerful and can be used to write a zip file management software similar
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.