Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
python3.7.4
/
Doc
/
library
/
marshal.rst
python3.7.4
/
Doc
/
library
/
marshal.rst
marshal.rst 4.74 KB
Copy Edit Raw Blame History
zhangweibo authored 2021年11月17日 13:49 +08:00 . git init

:mod:`marshal` --- Internal Python object serialization

.. module:: marshal
 :synopsis: Convert Python objects to streams of bytes and back (with different
 constraints).


This module contains functions that can read and write Python values in a binary format. The format is specific to Python, but independent of machine architecture issues (e.g., you can write a Python value to a file on a PC, transport the file to a Sun, and read it back there). Details of the format are undocumented on purpose; it may change between Python versions (although it rarely does). [1]

.. index::
 module: pickle
 module: shelve

This is not a general "persistence" module. For general persistence and transfer of Python objects through RPC calls, see the modules :mod:`pickle` and :mod:`shelve`. The :mod:`marshal` module exists mainly to support reading and writing the "pseudo-compiled" code for Python modules of :file:`.pyc` files. Therefore, the Python maintainers reserve the right to modify the marshal format in backward incompatible ways should the need arise. If you're serializing and de-serializing Python objects, use the :mod:`pickle` module instead -- the performance is comparable, version independence is guaranteed, and pickle supports a substantially wider range of objects than marshal.

Warning

The :mod:`marshal` module is not intended to be secure against erroneous or maliciously constructed data. Never unmarshal data received from an untrusted or unauthenticated source.

.. index:: object; code, code object

Not all Python object types are supported; in general, only objects whose value is independent from a particular invocation of Python can be written and read by this module. The following types are supported: booleans, integers, floating point numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets, frozensets, dictionaries, and code objects, where it should be understood that tuples, lists, sets, frozensets and dictionaries are only supported as long as the values contained therein are themselves supported. The singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration` can also be marshalled and unmarshalled. For format version lower than 3, recursive lists, sets and dictionaries cannot be written (see below).

There are functions that read/write files as well as functions operating on bytes-like objects.

The module defines these functions:

.. function:: dump(value, file[, version])

 Write the value on the open file. The value must be a supported type. The
 file must be a writeable :term:`binary file`.

 If the value has (or contains an object that has) an unsupported type, a
 :exc:`ValueError` exception is raised --- but garbage data will also be written
 to the file. The object will not be properly read back by :func:`load`.

 The *version* argument indicates the data format that ``dump`` should use
 (see below).


.. function:: load(file)

 Read one value from the open file and return it. If no valid value is read
 (e.g. because the data has a different Python version's incompatible marshal
 format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The
 file must be a readable :term:`binary file`.

 .. note::

 If an object containing an unsupported type was marshalled with :func:`dump`,
 :func:`load` will substitute ``None`` for the unmarshallable type.


.. function:: dumps(value[, version])

 Return the bytes object that would be written to a file by ``dump(value, file)``. The
 value must be a supported type. Raise a :exc:`ValueError` exception if value
 has (or contains an object that has) an unsupported type.

 The *version* argument indicates the data format that ``dumps`` should use
 (see below).


.. function:: loads(bytes)

 Convert the :term:`bytes-like object` to a value. If no valid value is found, raise
 :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. Extra bytes in the
 input are ignored.


In addition, the following constants are defined:

.. data:: version

 Indicates the format that the module uses. Version 0 is the historical
 format, version 1 shares interned strings and version 2 uses a binary format
 for floating point numbers.
 Version 3 adds support for object instancing and recursion.
 The current version is 4.


Footnotes

[1] The name of this module stems from a bit of terminology used by the designers of Modula-3 (amongst others), who use the term "marshalling" for shipping of data around in a self-contained form. Strictly speaking, "to marshal" means to convert some data from internal to external form (in an RPC buffer for instance) and "unmarshalling" for the reverse process.
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

No description
Cancel

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/python_sourcecode/python3.7.4.git
git@gitee.com:python_sourcecode/python3.7.4.git
python_sourcecode
python3.7.4
python3.7.4
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /