os.path.isfile() returns false for file on network drive

后端 未结 1 1587
长情又很酷
长情又很酷 2021-01-22 19:20

I am trying to test if a file exists on the network drive using os.path.isfile however it returns false even when the file is there. Any ideas why this might be or any other met

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-22 19:21

    From python https://docs.python.org/2/library/os.path.html:

    The os.path module is always the path module suitable for the operating system Python is running on, and therefore usable for local paths

    Trying using the full UNC path instead of the mapped drive.

    import os
    
    if os.path.isfile(r"\\full\uncpath\test.txt"):
        print "Is File"
    else:
        print "Is Not File"
    

    0 讨论(0)
提交回复
热议问题