以下のコードは、特定の接頭辞/接尾辞で始まり/終わる単語を示しています。リスト/ファイル中の特定の接頭辞/接尾辞で始まり/終わるすべての単語を見つけよう
string_list = [line.strip() for line in open("file.txt", 'r')]
for word in string_list:
if word[-1] == "a":
print word
string_list = [line.strip() for line in open("file.txt", 'r')]
for word in string_list:
if word[0] == "fi":
print word
どのようにすれば、巨大なデータに対して本当に速くなるように最適化できますか? また、どのように私は、事前に
python test.py --prefix fi
python test.py --suffix o
おかげのようなのparamを渡すことができます。
は[argparse](https://docs.python.org/3/library/argparse.htmlを見てみましょう)paramsを渡すために –
これを代わりに[codereview](http://codereview.stackexchange.com)に投稿してください。 –
sys.argv []とargparseの両方の使い方は? –