推荐学习书目
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
xylsmmmmmmmm3
V2EX  ›  Python

用 str 转成字符串和 join 转成字符串有什么区别?

  •  
  •   xylsmmmmmmmm3 · Sep 14, 2017 · 3774 views
    This topic created in 3175 days ago, the information mentioned may be changed or developed.
    4 replies    2017-09-15 11:39:06 +08:00
    petelin
        1
    petelin  
       Sep 14, 2017
    a['a'] 是个列表, str 的时候,就是那么打印的

    ''.join(a['a']) .........

    算了我懒得吐槽了..... 两个方法都不一样. 为什么你会认为输出一定要一样?
    aixia0124
        2
    aixia0124  
       Sep 14, 2017 via iPhone
    不是一个东西,还有为什么用 a['a']这种怪异的动作。

    如果你把字符串当成一个对象,那 join 就是这个对象的一个方法,好像接收的参数是一个可迭代对象。

    str 是不同的函数
    aaronzjw
        3
    aaronzjw  
       Sep 14, 2017
    str(a['a']) 不懂对列表用 str 什么意思
    flyingghost
        4
    flyingghost  
       Sep 15, 2017
    先看书,再提问。
    你这问题本身就不及格。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3597 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 71ms · UTC 04:50 · PVG 12:50 · LAX 21:50 · JFK 00:50
    ♥ Do have faith in what you're doing.