Ray's playground

 

2010年12月19日

Recipe 1.7. Reversing a String by Words or Characters(Python Cookbook)

摘要: reverseCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1astring="helloray"2revwords=astring.split()3revwords4['hello','ray']5revwords.reverse()6revwords7['ray','hello']8revwords=''.join(revwords)9revwords10'rayhello'11importre 阅读全文

posted @ 2010-12-19 14:21 Ray Z 阅读(159) 评论(0) 推荐(0)

Recipe 1.6. Combining Strings(Python Cookbook)

摘要: stringCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--1importoperator2pieces=['a','b','c']3largestring=reduce(operator.add,pieces)4largestring5'abc'6faststring=''.join(pieces)7faststring8'abc'9formatstring='%sis%s'%('ray','coding 阅读全文

posted @ 2010-12-19 11:43 Ray Z 阅读(146) 评论(0) 推荐(0)

导航