无法使用os.startfile访问远程服务器上的文件

时间:2020-11-04 20:19:33

标签: python windows

我正在尝试使用os.startfile命令访问服务器上的测试文本文件,但似乎无法使它工作。我知道它只会失败,因为文本文件在服务器上而不在计算机上,但我不知道如何访问它。

这是我的代码:

from os import startfile
path = "//10.2.30.61/c$/Qlikview_Tropal/Raport/test1.txt"
startfile("//10.00.00.00/c$/test/test1/test1.txt")

我收到此错误:FileNotFoundError:[WinError 2]。顺便说一下,我在窗户上。

Update_1:我尝试了enter os.startfile(os.path.normpath()),但收到了以下错误消息:“ filenotfounderror winerror 53找不到网络路径”

谢谢!!

1 个答案:

答案 0 :(得分:0)

你可以做

from os import start file


#put two \\ to get one \
path = "\\\\10.2.30.61\\c$\\Qlikview_Tropal\\Raport\\test1.txt"
startfile(r"\\10.00.00.00\c$\test\test1\test1.txt")

https://stackoverflow.com/a/43205543/14579156