Add a string to a Python list

This question already has an answer here:

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

  • Use append :

    >>> movie_list = []
    >>> movie_list.append('Espas en Hollywood')
    >>> movie_list
    ['Espas en Hollywood']
    

    If you want to use extend :

    movie_list.append(['Espas en Hollywood'])
    
    链接地址: http://www.djcxy.com/p/22558.html

    上一篇: 合并由`re.findall()`返回的列表

    下一篇: 将一个字符串添加到Python列表中