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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -