摘要: Python中的strip用于去除字符串的首位字符,同理,lstrip用于去除左边的字符,rstrip用于去除右边的字符。这三个函数都可传入一个参数,指定要去除的首尾字符。注意的是,传入的是一个字符数组,编译器去除两端所有相应的字符,直到没有匹配的字符,比如:Code highlighting produced by Actipro CodeHighlighter (freeware)http:/... 阅读全文
posted @ 2008-05-02 19:11 CoderZh 阅读(3400) 评论(9) 推荐(1) 编辑
摘要: Python中打印字符串时可以调用ljust(左对齐),rjust(右对齐),center(中间对齐)来输出整齐美观的字符串,使用起来非常简单,包括使用第二个参数填充(默认为空格)。看下面的例子就会明白了:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--... 阅读全文
posted @ 2008-05-02 18:36 CoderZh 阅读(3156) 评论(4) 推荐(1) 编辑
摘要: Python中判度对象类型方法非常简单,不需要像别的语言一样使用如下的判断方法:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--if(typeof(objA)==typeof(String)){//TODO}在Python中只需要使用内置的函数isin... 阅读全文
posted @ 2008-05-02 16:47 CoderZh 阅读(4772) 评论(1) 推荐(2) 编辑
摘要: Python提供了ord和chr两个内置的函数,用于字符与ASCII码之间的转换。如:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->>>printord('a')97>>>printchr(97)a下面我们可以开... 阅读全文
posted @ 2008-05-02 16:24 CoderZh 阅读(3941) 评论(4) 推荐(1) 编辑