python - Permission Denied To Write To My Temporary File -


I am trying to create and write a temporary file on Windows OS using Python. I used Python module tempfile to create a temporary file.

But when I write that temporary file, I get an error permission denied . Do not I have permission to write in temporary files?! Am I doing something wrong? If I want to create and write a temporary file, how should I do it in Python? I want to make a temporary file in the temporary file for security purposes and not locally (.dir is executed in .dir).

IOError: [Errno 13] Permission denied: 'c: \\ user \\ blaza ~ 1 \\ apeda \\ local \\ temp \\ tmpiwz8qw'

  temp = tempfile.NamedTemporaryFile (). Name # f = open (temp, 'w') on this line # error occurs    

< P> identical file named actually creates the file for you , there is no need to open it for you to type.

In fact, the state:

Whether the name can be used to open the file a second time, while the nominal temporary file is still open, the platform is different (It can be used on Unix; it can not be on Windows NT or later )

This is the reason why you are getting your permission error that you may be later:

  f = tempfile.NamedTemporaryFile (mode = 'w') # Open file temp = f.name # get name (if needed)    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -