简体   繁体   English

在Windows下用Python连接UNC路径

[英]Concatenate UNC path under Windows in Python

Using Python 3, looking for a nudge in the right direction because raw_input isn't behaving like I thought. 使用Python 3,寻找正确方向的微调,因为raw_input的行为不像我想的那样。

self.softwareOptions = {'1': "\X", '2': "\Y", '3':"\Z"}
self.sourceSoftware=r"\\Cdc1\cdc\Visual Studio 2015\Projects\WPF 2015 Projects"
self.sourceAppend=r"\JCOutput\Release"

    def BuildSourcePath(self):
        return os.path.join(self.sourceSoftware , self.selectedSoftware, self.sourceAppend)

At another point in the program the user is queried to enter 1,2,3 to append the appropriate path. 在程序的另一点,要求用户输入1,2,3以附加适当的路径。 The output, however, always cuts the path off at \\V, so I end up with \\cdc1\\cdc\\JCOutput\\Release 但是,输出总是在\\ V处切断路径,因此我最终得到\\ cdc1 \\ cdc \\ JCOutput \\ Release

You have to use relative paths: 您必须使用相对路径:

self.softwareOptions = {'1': "X", '2': "Y", '3':"Z"}
self.sourceSoftware=r"\\Cdc1\cdc\Visual Studio 2015\Projects\WPF 2015 Projects"
self.sourceAppend=r"JCOutput\Release"

def BuildSourcePath(self):
    return os.path.join(self.sourceSoftware, self.selectedSoftware, self.sourceAppend)

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

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