简体   繁体   English

Python识别cygwin上的UNC路径

[英]Python to recognize UNC path on cygwin

All machines are on Windows Server 2003. 所有计算机都在Windows Server 2003上。

If I only install cygwin on one of the machine and run my python script on it to manipulate files from all remote hosts. 如果我只在其中一台机器上安装cygwin并在其上运行我的python脚本来操作来自所有远程主机的文件。 How can I access to those files via UNC path? 如何通过UNC路径访问这些文件?

Cygwin understands UNC pathnames that use two forward slashes (as opposed to the two backslashes typical of Windows -- in fact, under Cygwin, you must use forward slashes instead of backslashes anywhere in the path). Cygwin了解使用两个正斜杠的UNC路径名(与Windows典型的两个反斜杠相反 - 实际上,在Cygwin下,您必须在路径中的任何位置使用正斜杠而不是反斜杠)。 I assume that this support would be propagated through to Python running on top of Cygwin, but I haven't ever tried it to confirm. 我假设这个支持将传播到运行在Cygwin之上的Python,但我还没有尝试过它来确认。

Edit: if you don't need to run python under cygwin, as you mention in a comment, then why are you doing so? 编辑:如果您不需要在cygwin下运行python,正如您在评论中提到的那样,那么您为什么这样做? Just install the native windows python from the python download site and forget about Cygwin. 只需从python下载站点安装本机windows python,忘记Cygwin。 You'll probably have to double your backslashes in the path names, however, since IIRC Python uses backslash as an escape character, so to get one backslash in the final string you need to put in two. 但是,您可能必须在路径名中加倍反斜杠,因为IIRC Python使用反斜杠作为转义字符,因此要在最终字符串中获得一个反斜杠,您需要将其放入两个中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM