Advertisement
Guest User

Untitled

a guest
Mar 26th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. C:Documents and SettingsAdministrator>python
  2. Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32
  3. Type "help", "copyright", "credits" or "license" for more information.
  4. >>> import tempfile
  5. >>> __, filename = tempfile.mkstemp()
  6. >>> print filename
  7. c:docume~1admini~1locals~1temptmpm5clkb
  8. >>> fptr = open(filename, "wb")
  9. >>> fptr.write("Hello World!")
  10. >>> fptr.close()
  11. >>> import os
  12. >>> os.remove(filename)
  13. Traceback (most recent call last):
  14. File "<stdin>", line 1, in <module>
  15. WindowsError: [Error 32] The process cannot access the file because it is being used by
  16. another process: 'c:\docume~1\admini~1\locals~1\temp\tmpm5clkb'
  17.  
  18. >>> __, filename = tempfile.mkstemp()
  19. >>> fptr= os.fdopen(__)
  20.  
  21. fh, filename = tempfile.mkstemp()
  22. ...
  23. os.close(fh)
  24. os.remove(filename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement