私は特定の書式設定を使ってtxtファイルを新しいtxtファイルに変換しようとしていますので、ウェブサイトに直接置くことができます。ループ内のリスト項目の参照部分
統計情報の見出しの下にある項目の統計情報というリストを作成しましたが、テキストを特定の方法でフォーマットするようにループを作成しようとしていますが、無効な構文エラーが表示されます。ここで
は..私がこれまで持っているもの
txt = open(html_file, 'a')
txt.write('<h5><a href="http://www.learningplusuk.org/data/education-reform" target="_blank"><strong>Education Reform</strong></a></h5>'
'\n'
'<p>All the latest information on qualification reform can be found via our website, in the ‘Education Reform’ section.</p>'
'\n'
'<hr>'
'\n'
'<p>Statistics and Data</p>'
'\n'
'<hr>'
'\n')
for i in stats:
j,k = enumerate(stats.split("\t"))
txt.write('<h5><a href=/"'i.split("\t")[4]'" target="_blank"><strong>'i.split("\t")[1]'</strong></a></h5>'
'\n'
'<h5><strong>'i.split("\t")[2]'</strong></h5>'
'<p>'i.split("\t")[3]'<br></p>'
'<hr>'
'\n')
txt.close()
ですが、それはi.splitが無効な構文であると言います。助言がありますか?
ありがとうございます!
あなたは文字列を連結しようとしていますか?はい、これは構文エラーです... 'txt.write( '
'stats'の内容が来ていないことを願っています(あなたのウェブページへのランダムな訪問者)から: –
あなたはそのような文字列を連結することはできません。それを行うには多くの方法がありますが、 ''