with open

Solutions on MaxInterview for with open by the best coders in the world

showing results for - "with open"
Angela
26 Nov 2016
1with open('output.txt', 'w') as file:  # Use file to refer to the file object
2
3    file.write('Hi there!')
Maya
04 Aug 2017
1with open('songs.txt') as f,open('songs_out.txt', 'w') as f_out:
2    for line in f:
3        line = line.strip()
4        if line.startswith("#EXTINF"):
5            f_out.write(f'{line}\n')
6            name = line.split(",")[1]
7            f_out.write(f'{name}.mp3\n')
8