strip 用法
来源:互联网 发布:端口聚合命令 编辑:程序博客网 时间:2024/05/30 05:15
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命令用法
- strip 命令的用法
- strip 命令的用法
- strip 命令的用法
- python strip()的用法
- python strip用法
- python strip lstrip rstrip 用法
- Linux strip命令的用法
- Linux strip命令的用法
- Linux strip命令的用法
- Linux strip命令的用法
- Linux strip命令的用法
- python strip lstrip rstrip用法
- strip
- UVA 11882 Biggest Number (dfs搜索+bfs 剪枝)
- #cs231n#相关资源
- 析构函数
- 机器学习之先验分布,后验分布,共轭先验分布
- SSH框架搭建
- strip 用法
- Java 流(Stream)、文件(File)和IO
- react-webpack 照片墙制作(二)
- poj 1511 spfa 模板题
- WUSTOJ 1961 神奇的序列
- 洛谷树
- C中printf与scanf的使用方法
- strip函数
- 尚观嵌入式c语言编程进阶笔记——2.数组