-3

I am trying to write file in remote windows server using network drive concept but failed to find network location:

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

Please suggest me alternative options.

ᴀʀᴍᴀɴ
  • 4,443
  • 8
  • 37
  • 57
Siva kumar Reddy
  • 97
  • 1
  • 1
  • 8
  • 2
    Possible duplicate of [How to write string literals in python without having to escape them?](http://stackoverflow.com/questions/4703516/how-to-write-string-literals-in-python-without-having-to-escape-them) – Keith Hall Jan 20 '16 at 11:34
  • "failed to find network location" How can you tell? Post any error messages. – DBedrenko Jan 20 '16 at 11:57

2 Answers2

1

Try with this:

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')
bit
  • 427
  • 1
  • 6
  • 14
0

Use Paramiko module in python for create SFTP session then you can transfer or create and write files to remote or remote to local

sathish
  • 149
  • 9