私はissuseを持っています解決できないようです。これが重複していても真実の答えに遭遇したことがないなら、謝罪してください。私は、テキストのブロックで情報を表示する設定ファイルから特定の情報を抽出しています。見出しを付けずに特定のブロックだけを出力する必要があります。ここで 特定のヘッダの後のPython 3.xの印刷番号
# output could containmultiple headers, and lines, or no lines per header this is an example of what could be present but it is not absolute.
header1
-------
line1
line2
line3 # can be muiplies availables or known
header2
-------
line1
line2
line3 # can be muiplies availables or known
header3
-------
header4
-------
line1
line2
line3 # can be multiple linnes or none not known
は、私が始めたが、第2のループブールに貼り付けコードです:だから例えば(下のテキスト形式の)私はヘッダ2以下の情報ではなく、何も過去ヘッダ3をキャプチャしたいと思いますまたはそのヘッダブロックの行のみを印刷するためのロジック:
Raw_file = "scrap.txt"
scrape = open(Raw_file,"r")
for fooline in scrape:
if "Header" in fooline:
#print(fooline) # prints all lines
#print lines under header 2 and stop before header 3
scrape.close()
私もラインでオブジェクトを印刷したい場合、これは、優れたおかげで、どのように私は希望それを行う。私はそれを分割し、行[0]を印刷して '3'を得ようとしました。私は何かを理解していないかもしれないかもしれません。 – onxx