2016-01-20 83 views
-3

我想使用的網絡驅動器的概念寫在遠程Windows服務器上的文件,但沒能找到網絡位置:如何從本地python腳本在遠程windows服務器中寫入文件?

z = open("\\\\xxxxxxxx\Program Files\abc.txt") 
z.write('This is a test\n') 

請給我建議的替代方案。

+2

【如何寫串的可能的複製在python文字,而不必轉義他們?](http://stackoverflow.com/questions/4703516/how-to-write-string-literals-in-python-without-having-to-escape-them) –

+0

「失敗找到網絡位置「你怎麼知道?發佈任何錯誤消息。 – DBedrenko

回答

0

使用Paramiko模塊的Python爲創建SFTP會話,那麼你可以傳輸文件或創建並寫入到遠程或遠程到本地

0

試試這個:

from os import os.path 

filename = 'abc.txt' 
# use forward slash instead of back slash 
path = '//xxxxxxxx/Program Files/' 
outputfile = os.path.join(path, filename) 
output = open(outputfile, 'w') 
相關問題