Life is short, you need Python

摘要: join 方法用于连接字符串数组Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--s=['a','b','c','d']print''.join(s)print'-'.join(s)输出结果:abcda-b-c-d使用 % 连接多个变量Code high... 阅读全文
posted @ 2010-06-24 15:34 runfox545 阅读(408) 评论(0) 推荐(0)
摘要: Python中的strip用于去除字符串的首位字符,同理,lstrip用于去除左边的字符,rstrip用于去除右边的字符。这三个函数都可传入一个参数,指定要去除的首尾字符。注意的是,传入的是一个字符数组,编译器去除两端所有相应的字符,直到没有匹配的字符,比如:Code highlighting produced by Actipro CodeHighlighter (freeware)http:/... 阅读全文
posted @ 2010-06-24 15:22 runfox545 阅读(342) 评论(0) 推荐(0)
摘要: Python中打印字符串时可以调用ljust(左对齐),rjust(右对齐),center(中间对齐)来输出整齐美观的字符串,使用起来非常简单,包括使用第二个参数填充(默认为空格)。看下面的例子就会明白了:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--... 阅读全文
posted @ 2010-06-24 11:12 runfox545 阅读(246) 评论(0) 推荐(0)
白月黑羽 Python教程 白月黑羽Python