V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Livid
V2EX  ›  Python

请教一个关于 Python 的 list 的问题

  •  
  •   Livid · 2012-04-28 22:05:26 +08:00 · 2660 次点击
    这是一个创建于 4402 天前的主题,其中的信息可能已经有所发展或是发生改变。
    - Python 的 list 是带顺序的 ordered list,对吗?
    - 如果使用 Pickle 进行序列化和反序列化,是否会影响其中元素的顺序呢?
    4 条回复    1970-01-01 08:00:00 +08:00
    yuelang85
        1
    yuelang85  
       2012-04-28 22:16:55 +08:00   ❤️ 1
    不会影响。你可以序列化一下看看生成的字符串,是可以看出原始数据的。。。。
    Mattsive
        2
    Mattsive  
       2012-04-28 22:19:03 +08:00   ❤️ 1
    - The list type is a container that holds a number of other objects, in a given order.
    - Pickle 是把 object 转成字节流再还原 object 的,理论上 object 转换前后是完全一样的.
    phuslu
        3
    phuslu  
       2012-04-28 22:20:11 +08:00   ❤️ 1
    marshal的速度比pickle/cpickle要快些。
    reorx
        4
    reorx  
       2012-04-28 22:20:57 +08:00   ❤️ 1
    - 对的,这是Lists的基本特性。事实上,Lists是基础类别Sequences的衍生,也被称为“Mutable sequences“

    - 不会。可序列化的对象在被反序列化时,会完全还原为它被序列化时的状态。List中元素的顺序也会保持原样。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1283 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:44 · PVG 07:44 · LAX 16:44 · JFK 19:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.