650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>
import mmapmmap_file = none# #从内存中读取信息, Def read_mmap_info (): global mmap_file mmap_file.seek (0) ## Convert the binary to String info_str=mmap_file.read (). Translate (none, b ' \x00 '). Decode () print (INFO_STR) # #如果内存中没有对应信息, writes the information to memory for the next call to use Def get_mmap_info (): global mmap_file # #第二个参数1024是设定的内存大小, units: bytes. If you have more content, you can turn it up a little bit mmap_file = mmap.mmap ( -1, 1024, access = Mmap. access_write, tagname = ' Share_mmap ') # #读取有效比特数, excluding empty bits cnt=mmap_file.read_byte () if cnt==0: print ("Load data to memory") mmap_ File = mmap.mmap (0, 1024, ACCESS =&NBsp;mmap. access_write, tagname = ' Share_mmap ') mmap_ File.write (b "This is the test data") else : print ("The data is in memory") read_mmap_info () # #修改内存块中的数据def  RESET_MMP_INFO:    GLOBAL MMAP_ File mmap_file.seek (0) mmap_file.write (b ' \x00 ') mmap_file.write (b "Load data to memory agine") if __name__== "__main__": get_mmap_info () Description: If you are using a python-brought IDE, re-open this file once the results of running test data are loaded into memory
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>
Python, mmap for in-memory data sharing