掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流
這些例程允許 C 代碼處理與 marshal 模塊所用相同數(shù)據(jù)格式的序列化對象。 其中有些函數(shù)可用來將數(shù)據(jù)寫入這種序列化格式,另一些函數(shù)則可用來讀取并恢復數(shù)據(jù)。 用于存儲 marshal 數(shù)據(jù)的文件必須以二進制模式打開。

十年的綿竹網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。網(wǎng)絡營銷推廣的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調(diào)整綿竹建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)從事“綿竹網(wǎng)站設計”,“綿竹網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
數(shù)字值在存儲時會將最低位字節(jié)放在開頭。
此模塊支持兩種數(shù)據(jù)格式版本:第 0 版為歷史版本,第 1 版本會在文件和 marshal 反序列化中共享固化的字符串。 第 2 版本會對浮點數(shù)使用二進制格式。 Py_MARSHAL_VERSION 指明了當前文件的格式(當前取值為 2)。
void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
Marshal a long integer, value, to file. This will only write the least-significant 32 bits of value; regardless of the size of the native long type. version indicates the file format.
void PyMarshal_WriteObjectToFile(PyObject *value, FILE *file, int version)
將一個 python 對象 value 以 marshal 格式寫入 file。 version 指明文件格式的版本。
PyObject *PyMarshal_WriteObjectToString(PyObject *value, int version)
Return value: New reference.
返回一個包含 value 的 marshal 表示形式的字節(jié)串對象。 version 指明文件格式的版本。
以下函數(shù)允許讀取并恢復存儲為 marshal 格式的值。
long PyMarshal_ReadLongFromFile(FILE *file)
Return a C long from the data stream in a FILE* opened for reading. Only a 32-bit value can be read in using this function, regardless of the native size of long.
發(fā)生錯誤時,將設置適當?shù)漠惓?(EOFError) 并返回 -1。
int PyMarshal_ReadShortFromFile(FILE *file)
Return a C short from the data stream in a FILE* opened for reading. Only a 16-bit value can be read in using this function, regardless of the native size of short.
發(fā)生錯誤時,將設置適當?shù)漠惓?(EOFError) 并返回 -1。
PyObject *PyMarshal_ReadObjectFromFile(FILE *file)
Return value: New reference.
Return a Python object from the data stream in a FILE* opened for reading.
發(fā)生錯誤時,將設置適當?shù)漠惓?(EOFError, ValueError 或 TypeError) 并返回 NULL。
PyObject *PyMarshal_ReadLastObjectFromFile(FILE *file)
Return value: New reference.
Return a Python object from the data stream in a FILE* opened for reading. Unlike PyMarshal_ReadObjectFromFile(), this function assumes that no further objects will be read from the file, allowing it to aggressively load file data into memory so that the de-serialization can operate from data in memory rather than reading a byte at a time from the file. Only use these variant if you are certain that you won’t be reading anything else from the file.
發(fā)生錯誤時,將設置適當?shù)漠惓?(EOFError, ValueError 或 TypeError) 并返回 NULL。
PyObject *PyMarshal_ReadObjectFromString(const char *data, Py_ssize_t len)
Return value: New reference.
從包含指向 data 的 len 個字節(jié)的字節(jié)緩沖區(qū)對應的數(shù)據(jù)流返回一個 Python 對象。
發(fā)生錯誤時,將設置適當?shù)漠惓?(EOFError, ValueError 或 TypeError) 并返回 NULL。

我們在微信上24小時期待你的聲音
解答本文疑問/技術咨詢/運營咨詢/技術建議/互聯(lián)網(wǎng)交流