Python list .extend method breaks string into characters

This question already has an answer here:

  • Difference between append vs. extend list methods in Python 22 answers

  • list.extend extends the list with each of the items in the iterable you pass. A string is an iterable of characters, so it appends the characters.

    Easier to use list.append here.

    链接地址: http://www.djcxy.com/p/22562.html

    上一篇: 将子列表作为对象而不是列表复制到主列表中

    下一篇: Python列表.extend方法将字符串分解为字符