Esto me devuelve una ruta corta (convención de DOS) (en Windows):
import tempfile tempDir = tempfile.mkdtemp() print tempDir Output >>> c:\users\admini~1\appdata\local\temp\tmpf76unv
Note el admini~1
.
¿Cómo puedo obtener / convertir esto en una ruta completa? por ejemplo, C: \ users \ administrator \ appdata …
Por favor intente el siguiente código (actualizado):
from ctypes import create_unicode_buffer, windll BUFFER_SIZE = 500 buffer = create_unicode_buffer(BUFFER_SIZE) get_long_path_name = windll.kernel32.GetLongPathNameW get_long_path_name(unicode(short_path_name), buffer, BUFFER_SIZE) long_path_name = buffer.value
Espero que esto ayude. Consulte http://mail.python.org/pipermail/python-win32/2008-January/006642.html
tempDir = win32file.GetLongPathName(tempDir)