import sys nometxt = sys.argv[1] nomehtml = nometxt[:-4] + '.html' f_txt = open(nometxt,'r') f_html = open(nomehtml,'w') #scrivi intestazione f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('\n') f_html.write('

\n') lines = f_txt.readlines() inc=0 uguali = '=======================================\n' for line in lines: if line == uguali: f_html.write('\n') inc = inc + 1 line_html= line[:-1] + '
\n' f_html.write(line_html) # scrive chiusura f_html.write('

\n') f_html.write('\n') f_html.write('\n') # Chiude i file f_txt.close() f_txt.close()