Python Global File -
Python Global File -
how can write global file within of function?
example:
output_file=open("output_file_name.txt", "w") def write_to_file: global output_file output_file.write('something') write_to_file() output_file.close()
the code above not working. says "valueerror: i/o operation on closed file" ideas?
write_to_file function,
try
def write_to_file():
othrwise code fine
python
Comments
Post a Comment