Question

I am trying to open a file in a shared network location

open('\\int\GroupData\ITProSup\Operations Support\REMGROUP.txt','+r')

Now this turns into

nemonics>python main.py
eback (most recent call last):
le "main.py", line 41, in <module>
sys.exit(main())
le "main.py", line 36, in main
insert_file_into_db(con_S104838,open('\\int\GroupData\ITProSup\Operations Su
t\REMGROUP.txt','+r'))
NotFoundError: [Errno 2] No such file or directory: '\\int\\GroupData\\ITPro
\Operations Support\\REMGROUP.txt'

I have tried this thread Using Python, how can I access a shared folder on windows network? but it does note seem to work for me. I am running python 3.4.1 and its windows 2012 server.

I have also tried using os.path https://docs.python.org/3.4/library/os.path.html#os.path.normpath with not much luck

C:\mnemonics>python main.py
Traceback (most recent call last):
  File "main.py", line 41, in <module>
    sys.exit(main())
  File "main.py", line 36, in main
    insert_file_into_db(con_S104838, open(os.path.normpath('\\int\GroupData\ITPr
oSup\Operations Support\REMGROUP.txt')))
FileNotFoundError: [Errno 2] No such file or directory: '\\int\\GroupData\\ITPro
Sup\\Operations Support\\REMGROUP.txt'

C:\mnemonics>python main.py
Traceback (most recent call last):
  File "main.py", line 42, in <module>
    sys.exit(main())
  File "main.py", line 37, in main
    open(os.path.normcase('\\int\GroupData\ITProSup\Operations Support\REMGROUP.
txt'),'+r'))
FileNotFoundError: [Errno 2] No such file or directory: '\\int\\groupdata\\itpro
sup\\operations support\\remgroup.txt'

Any help would be greatly appreciated

Était-ce utile?

La solution

Note that \ should be escaped to \\, so \\ should be \\\\

Please try

'\\\\int\\GroupData\\ITProSup\\Operations Support\\REMGROUP.txt'

or

'//int/GroupData/ITProSup/Operations Support/REMGROUP.txt'
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top