How to split a string into an array of characters in Python?

前端 未结 13 1245
一整个雨季
一整个雨季 2020-11-22 01:54

I\'ve tried to look around the web for answers to splitting a string into an array of characters but I can\'t seem to find a simple method

str.split(//)

13条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 02:11

    You can use extend method in list operations as well.

    >>> list1 = []
    >>> list1.extend('somestring')
    >>> list1
    ['s', 'o', 'm', 'e', 's', 't', 'r', 'i', 'n', 'g']
    

提交回复
热议问题