15 个最佳开源设计工具
2012-04-08 07:05
211 查看
总结下最近学习lerning python这本书的字符串部分的一些收获吧。
一、原始字符串
在普通字符串前加‘r'即成为原始字符串,特点是抑制转义,即在原始字符串中’\n‘这种转义字符串没有特殊含义了。
二、索引和分片
s = 'abcdefg'
s[1:5:2] = 'ace'
s[5:1:-1] = 'fedc'
s[::-1] = 'gfedcba'
三、字符串转换工具
int('42') = 42
str(42) = '42'
ord('s') = 115
chr(115) = 's'
四、修改字符串
s = 'spam'
s[0] = 'a' error!!!不能原处修改
s = s + 'hello'
s = s[4:] + ' world' = 'hello world'
五、字符串方法
s = 'hello world'
(1) replace
s.replace( 'o', 'x' ) = 'hellx, wxrld'
(2) join
l = list( s ) = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
' '.join( l ) = 'hello world'
','.join( ['hello', 'world'] ) = 'hello,world'
'spam'.join( ['hello', 'world'] ) = 'hellospamworld'
(3) split
line = 'aaa bbb ccc'
line.split() = ['aaa', 'bbb', 'ccc'] //如果不加任何参数默认用空格来分割
line = 'bob,hacker,40'
line.split( ',' ) = ['bob', 'hacker', '40']
(4) rstrip, lstrip //分别是去除字符串右端和左端的空白
line = 'the knights who say hi!\n'
line.rstrip() = 'the knights who sya hi!' //去除行末的空白
(5) endswith, startswith //rt
(6) find
'hello, world'.find( 'o' ) = 4
本文出自 “sdu_IS” 博客,请务必保留此出处http://hychuanshuo.blog.51cto.com/2724628/1239093
一、原始字符串
在普通字符串前加‘r'即成为原始字符串,特点是抑制转义,即在原始字符串中’\n‘这种转义字符串没有特殊含义了。
二、索引和分片
s = 'abcdefg'
s[1:5:2] = 'ace'
s[5:1:-1] = 'fedc'
s[::-1] = 'gfedcba'
三、字符串转换工具
int('42') = 42
str(42) = '42'
ord('s') = 115
chr(115) = 's'
四、修改字符串
s = 'spam'
s[0] = 'a' error!!!不能原处修改
s = s + 'hello'
s = s[4:] + ' world' = 'hello world'
五、字符串方法
s = 'hello world'
(1) replace
s.replace( 'o', 'x' ) = 'hellx, wxrld'
(2) join
l = list( s ) = ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
' '.join( l ) = 'hello world'
','.join( ['hello', 'world'] ) = 'hello,world'
'spam'.join( ['hello', 'world'] ) = 'hellospamworld'
(3) split
line = 'aaa bbb ccc'
line.split() = ['aaa', 'bbb', 'ccc'] //如果不加任何参数默认用空格来分割
line = 'bob,hacker,40'
line.split( ',' ) = ['bob', 'hacker', '40']
(4) rstrip, lstrip //分别是去除字符串右端和左端的空白
line = 'the knights who say hi!\n'
line.rstrip() = 'the knights who sya hi!' //去除行末的空白
(5) endswith, startswith //rt
(6) find
'hello, world'.find( 'o' ) = 4
本文出自 “sdu_IS” 博客,请务必保留此出处http://hychuanshuo.blog.51cto.com/2724628/1239093
相关文章推荐
- IBM发布开源HTML5可视化设计工具Maqetta
- 最佳开源应用程序:开发工具
- Linux和类Unix系统上5个最佳开源备份工具
- 最佳的 14 个免费的响应式 Web 设计测试工具
- 15 个开源的顶级人工智能工具
- 最佳开源应用程序:开发工具
- 10款人工智能和机器学习领域方面的开源项目。15 个开源的顶级人工智能工具,人工智能和机器学习领域中有趣的开源项目
- 2017 年最佳开源网络监控工具
- 为您的软件系统设计选择最佳的工具
- 五大最佳开源java性能监控工具
- Balsamiq Mockups 3.5.7 for Windows / Mac 简体中文汉化 最佳原型设计工具之一
- Framer:开源原型设计工具,巨头们的心头好
- 分享12款最佳的Bootstrap设计工具
- 10款人工智能和机器学习领域方面的开源项目。15 个开源的顶级人工智能工具,人工智能和机器学习领域中有趣的开源项目
- Free Download Manager (FDM) 中文版 - 替代迅雷最佳免费开源下载工具软件
- 5 个 iOS 和 Android 最佳的开源自动化工具
- Maqetta Preview 2 发布,开源HTML5可视化设计工具
- 【转】MAQETTA: 基于HTML5的开源可视化界面设计工具