And*_*ndi 7 python windows path
这给我一个短路径(DOS约定)(在Windows上):
import tempfile
tempDir = tempfile.mkdtemp()
print tempDir
Output >>> c:\users\admini~1\appdata\local\temp\tmpf76unv
Run Code Online (Sandbox Code Playgroud)
请注意admini~1.
如何将其转换为完整路径?例如C:\ users\administrator\appdata ...
Sud*_*nan 10
请尝试以下代码(更新):
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
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.请参阅http://mail.python.org/pipermail/python-win32/2008-January/006642.html
| 归档时间: |
|
| 查看次数: |
2784 次 |
| 最近记录: |