#!/usr/bin/python #this looks for words in dictionary that begin with 'in' and the suffix is a real word wordlist = [line.strip() for line in open('/usr/share/dict/words')] newlist = [] for word in wordlist: if word.startswith("in"): newlist.append(word) for word in newlist: word = word.split('in') print newlist
「in」という文字列を、それが始まるすべての単語から削除するにはどうすればよいですか?今すぐ動作しませんpython - 配列内の単語から文字列を削除する
「in」という接頭辞が付いている単語のみを検索している場合、「in」で始まるすべての単語が他の単語とは逆のものではないことに注意してください。例えば、「腸」、「注射」など – BoltClock
@BoltClock:そういう場合、「睾丸」と「ject」は単語ではありません。しかし、 "inquest"は問題になります。 –
@Davidドイツ語:まったく。 – BoltClock