<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>
    ???? Python ???
    ??12?? ????/???
    ???? ?????? ????

    ??????

    Python????????????ï…???pickle?????????????????????§Õ????¦Ê?Python?????????????????????????????????????? ???? ???????

    ??????????????cPickle??????????pickle??????????????????????C?????§Õ?????????????pickle??1000???????????????????§Ö???????????????????????cPickle??î•??????????????????úY????pickle??î•

    ???????????

    ??12.2 ???????????

    #!/usr/bin/python
    # Filename: pickling.py


    import cPickle as p
    #import pickle as p

    shoplistfile = 'shoplist.data'
    # the name of the file where we will store the object

    shoplist = ['apple', 'mango', 'carrot']

    # Write to the file
    f = file(shoplistfile, 'w')
    p.dump(shoplist, f)
    # dump the object to a file
    f.close()

    del shoplist # remove the shoplist

    # Read back from the storage

    f = file(shoplistfile)
    storedlist = p.load(f)

    print storedlist

    ????????code/pickling.py??

    ???

    $ python pickling.py
    ['apple', 'mango', 'carrot']

    ????¦É???

    ???????????????????import..as?????????????????????????????????????????????????????????§µ?????????????????????????§à??§Ý??????????ð‹cPickle????pickle????????????????????????????????????p??

    ?????????????????????????§Õ???????file???????????????????dump????????????›Ô????????§³?????????? ???? ??

    ???????????????pickle????load?????????????????????????? ????? ??


    ???? ????? ????
    ??? ??? ????
    ?????
    @ssv 97av