I've run into a bit of a snag with a python script that I was hoping anyone with a fresh pair of eyes and a bit more expertise than myself could spot. I compile, build, and execute the code in Geany if that matters at all. I am getting an error back suggesting a "ValueError I/O operation on closed file". line 8 specifically the f.write("Appended line %d r\n % (i+1))"
def main (_): """ Function doc """ f= open("AlltheRocks.txt", "a+") for i in range(2): f.write("Appended line %d\r\n" % (i+1)) f.close() if __name__== "__main__": main() If any help could be pointed out that would be amazing. I am ultimately trying to see if I can write a single program that opens, writes, and appends multiple text files from potentially different websites as well is that possible?
https://stackoverflow.com/questions/65589214/open-write-and-append-a-text-file January 06, 2021 at 10:04AM
没有评论:
发表评论