Python 实现字符串转换成列表 实现str转换list

其中Python strip() 方法用于移除字符串头尾指定的字符

split()就是将一个字符串分裂成多个字符串组成的列表

>>> image ='1.jsp,2.jsp,3.jsp,4.jsp'
>>> image_list = image.strip(',').split(',')
>>> print image_list
['1.jsp', '2.jsp', '3.jsp', '4.jsp']
>>> 

 

转载于:https://www.cnblogs.com/xuchunlin/p/6676288.html