Answers for "how to convert a string list txt file in python"

7

convert python list to text file

# define list of places
places = ['Berlin', 'Cape Town', 'Sydney', 'Moscow']

with open('listfile.txt', 'w') as filehandle:
    for listitem in places:
        filehandle.write('%s\n' % listitem)
Posted by: Guest on August-20-2020
0

convert text file into list

crimefile = open(fileName, 'r')
yourResult = [line.split(',') for line in crimefile.readlines()]
Posted by: Guest on May-25-2021

Code answers related to "how to convert a string list txt file in python"

Python Answers by Framework

Browse Popular Code Answers by Language