strip函数
来源:互联网 发布:端口聚合命令 编辑:程序博客网 时间:2024/06/05 09:01
1
2
3
4
5
6
7
8
>>> a=
'hheloooo goooodbyyyye'
>>> a.strip(
'helo '
)
'goooodbyyyy'
>>> a.strip(
'he'
)
'loooo goooodbyyyy'
>>> a.strip(
'o'
)
'hheloooo goooodbyyyye'
>>>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
>>> a=
' a\n\tbc'
>>> print a
a
bc
>>> a.strip()
'a\n\tbc'
>>> a=
' abc'
>>> a.strip()
'abc'
>>> a=
'\n\tabc'
>>> a.strip()
'abc'
>>> a=
'abc\n\t'
>>> a.strip()
'abc'
>>>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
>>> a=
'123abc'
>>> a.strip(
'21'
)
'3abc'
>>> a.strip(
'12'
)
'3abc'
>>> a.strip(
'1a'
)
'23abc'
>>> a.strip(cb)
Traceback (most recent call last):
File
"<stdin>"
, line 1,
in
<module>
NameError: name
'cb'
is not defined
>>> a.strip(
'cb'
)
'123a'
>>> a.strip(
'bc'
)
'123a'
>>>
1
2
3
>>> a=
'a b c d'
>>> a.
split
()
[
'a'
,
'b'
,
'c'
,
'd'
]
1
2
3
>>> b=
'abc efg hij kkj'
>>> b.
split
()
[
'abc'
,
'efg'
,
'hij'
,
'kkj'
]
1
2
3
4
5
>>> c=
'name=ding|age=25|job=it'
>>> c.
split
(
'|'
)
[
'name=ding'
,
'age=25'
,
'job=it'
]
>>> c.
split
(
'|'
)[0].
split
(
'='
)
[
'name'
,
'ding'
]
1
2
3
4
5
6
7
8
9
10
11
>>> d=
'a b c d e'
>>> d.
split
(
' '
,1)
#以空格“切一刀”,就分成两块了
[
'a'
,
'b c d e'
]
>>> d.
split
(
' '
,2)
[
'a'
,
'b'
,
'c d e'
]
>>> d.
split
(
' '
,3)
[
'a'
,
'b'
,
'c'
,
'd e'
]
>>> d.
split
(
' '
,-1)
#d.split(' ')结果一样
[
'a'
,
'b'
,
'c'
,
'd'
,
'e'
]
>>> d.
split
(
' '
)
[
'a'
,
'b'
,
'c'
,
'd'
,
'e'
]
0 0
- strip函数
- strip()函数
- strip函数
- strip函数
- strip()函数。
- makefile strip函数
- python strip()函数 介绍
- python strip()函数 介绍
- python strip()函数
- python中的strip函数
- python strip()函数 介绍
- python strip()函数
- Python的strip函数
- python strip()函数
- python strip() split()函数
- python strip()函数
- python strip()函数
- python strip()函数
- react-webpack 照片墙制作(二)
- poj 1511 spfa 模板题
- WUSTOJ 1961 神奇的序列
- 洛谷树
- C中printf与scanf的使用方法
- strip函数
- 尚观嵌入式c语言编程进阶笔记——2.数组
- 【名词】JPA、JTA、JMS、CRUD
- 任务,线程和同步(五)之(Thread类)线程类
- UVA 1586 分子量(简单模拟计算)
- ui_qtproject.h
- nmon的使用1
- eps在MATLAB中是什么意思
- Java的包机制