lzstring is a Python port of the JavaScript lz-string library, providing efficient in-memory compression and decompression of strings. It supports various encoding formats like Base64, UTF16, and raw binary, making it suitable for compact data storage or transfer, especially when interoperating with JavaScript applications. The current version is 1.0.4, and the library is mature and stable with infrequent updates.
pip install lzstringVerified import paths — ran on the pinned version, not inferred.
Initialize LZString and compress/decompress a simple string using its default and Base64 methods. Demonstrates basic usage and ensures data integrity.
Always match the compression method variant (e.g., `compressToUTF16`, `compressToBase64`) with its corresponding decompression method (e.g., `decompressFromUTF16`, `decompressFromBase64`).
Ensure all input for compression is a Python `str`. If you have `bytes` data, decode it to a `str` first (e.g., `my_bytes.decode('utf-8')`).Use the correct camelCase method name, e.g., `lzs.compressToBase64()` instead of `lzs.compress_to_base64()`.
Verify the integrity and origin of the compressed data. Ensure it was compressed using `lzstring` (or a compatible JavaScript `lz-string`) and that you are using the correct decompression method. If the error occurs on input, ensure your input is a valid Python `str`.
No dependency data recorded yet.