2
は.txtファイルの行数をカウントします。文字列には2つのサブストリングが含まれています。文字列中の文字列内のサブストリングを数える方法 - Python
私は次のことを試してみました:
with open(filename, 'r') as file:
for line in file:
wordsList = line.split()
if any("leads" and "show" in s for s in wordsList):
repetitions +=1
print "Repetitions: %i" % (repetitions)
をしかし、それはそれが必要として動作していないようです。それは2であるべきときに私は3回繰り返しを得た次のデモ入力ファイルを使用して :
www.google.es/leads/hello/show
www.google.es/world
www.google.com/leads/nyc/oops
www.google.es/leads/la/show
www.google.es/leads/nope/pop
leads.
show
私はまた、「すべて」のために「あらゆる」をchaning試みたが、私も他人の結果を得ます。
あなたはS' –
@ThierryLathuilleでs内の '「リード」と「ショー」を意味し、それが働いた神ああありがとうございました! – ignasibm