TypeError: coercing to Unicode: need string or buffer, file found in python(writing data from existing files into single file) -
i supposed write data 3 existing files single file in python. faced error "typeerror: coercing unicode: need string or buffer", file found. 3 existing files e, g , m , made file named results writing data 3 mentioned existing files. appreciate help
filenames= [e,g,m] open(results, "w") outfile: file in filenames: open(file) infile: line in infile: outfile.write(line)
your filename should string. filename e, m, g should "e", "m", "g", result should "result". refer code below:
#!/usr/bin/python # -*- coding: utf-8 -*- filenames= ["e","g","m"] open("results", "w") outfile: file in filenames: open(file) infile: line in infile: outfile.write(line)
Comments
Post a Comment