首页 > 编程语言 > 详细

Python 过滤重复单词

时间:2014-09-24 21:29:48      阅读:392      评论:0      收藏:0      [点我收藏+]

描述:一个英文句子仅由单词、逗号、句号、空格组成。要求过滤句子中的重复单词,例如:输入where there is a will, there is a way.

输出:where there is a will way

str = raw_input("");
a = []
str = str.replace(",", "").replace(".", "")
a = str.split(" ")
b = sorted(set(a),key=a.index)
for x in b:
    if x !="":
        print x,

  

Python 过滤重复单词

原文:http://www.cnblogs.com/purple-blog/p/3991483.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!