==================== 演示了Python中的字符串通过split分割后的使用和把分割后的字符串连接起来 #!/usr/bin/env python str = ("i am a worker, and you are a student !") print str #split the str,if not specified the separator ,the whitespace is a separator,items is a sequence items = str.split() print items #join the str sep=":" items=sep.join(items) print items 执行这个脚本2.py,得到的结果为: i am a worker, and you are a student ! ['i', 'am', 'a', 'worker,', 'and', 'you', 'are', 'a', 'student', '!'] i:am:a:worker,:and:you:are:a:student:!
posted on 2012-05-13 15:15  fengidri  阅读(265)  评论(0编辑  收藏  举报