私は以下を使用して段落から文字列を抽出しました。正規表現を使用して段落の特定のテキストを抽出します
data = '''actions/steps to (re-) produce the problem:
1) Media--> Music collectio--> on right side--> click on Add Favourite icon--> on clicking Add from Favourite icon--> (Delete from favourite) will display--> again click on Delete the favourite
expected result/behaviour:
it should display the track as well
observed result/behavior:
1st track list will display then
2nd list of songs will display
3rd no records will display
this behaviour will appear again and again
possible impact:
this can be an issue while driving
actions/steps to recover from error:
software version tested (including supplied software or CAF version if relevant):
MGU :- 17w.25.4-2'''
observed=[]
for i in data["Error Description"]:
if len(re.findall(r'(Observed result\/behavior:|observed result\/behavior:)([^(]*)Possible impact:', i))==1:
observed.append((re.findall(r'(Observed result\/behavior:|observed result\/behavior:)([^(]*)Possible impact:', i))[0][1])
else:
observed.append(" ".join((re.findall(r'(Observed result\/behavior:|observed result\/behavior:)([^(]*)Possible impact:', i))))
OUTPUT:4行があります。
それは "観察" として何も表示されません。一般に1行があり、その直前に「可能な影響:」と表示されている場合は、出力が表示されます。
観察を持っていないn行
の何が助けてください場合でも、私は私の出力を必要としています。
は 'あなたが提供data'、あなたが希望する出力を明確にしてくださいだろう与えられました。つまり、出力がどのように表示されると思いますか? – athraa
出力には「観察された」データのみが含まれます。例えば、上記の場合、出力は観察結果/動作のみでなければなりません:最初のトラックリストが表示され、2番目の曲のリストが表示されます3番目のレコードは何も表示されませんこの動作は何度も繰り返されます " – pylearner