python 字符串split的用法分享

WBOY
Release: 2016-06-06 11:27:55
Original
1120 people have browsed it

比如我们的存储的格式的:

格式的:

姓名,年龄|另外一个用户姓名,年龄

name:haha,age:20|name:python,age:30|name:fef,age:55

那我们可以通过字符串对象的split方法切割字符串对象为列表。

a = 'name:haha,age:20|name:python,age:30|name:fef,age:55'

print a.split('|')

返回结果:

['name:haha,age:20', 'name:python,age:30', 'name:fef,age:55']
通过上面的介绍,相信你对python string split有一个比较好的了解

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template