在Python中,如何处理以句点结尾的文件名?根据MSDN的网站,这样的文件名在Windows中是有效的,但是每当我试图用Python创建一个文件名时,它就会删除最后一个句点。我甚至尝试用os.open创建一个原始文件描述符,但它仍然删除了句点。
例如,这将创建一个名为“test
”的文件
os.open('test.', os.O_CREAT | os.O_WRONLY, 0777)
About spaces and dots in filenames and directories. The limits are in the windows shell -- not in Windows or NT. Using 'bash', you can create files with spaces (or dots), both, at the beginning and end of a filename. You can then list and open those files in explorer, and you can 'list' them in the shell (cmd.exe), but you won't necessarily be able to open them from the shell (especially trailing spaces and dots).
目前没有回答
相关问题 更多 >
编程相关推荐