Skip to main content
 首页 » 编程设计

带有 Windows 共享文件夹的 Python3

2024年12月31日11pengyingh

我正在尝试从 windows 共享文件夹中获取文件,但它显示错误

FileNotFoundError: [WinError 3] 系统找不到指定的路径:

因为我尝试了以下选项:

  • print (os.listdir('\\piyushtech\techtech$\Piyush\Optimized Version'))
  • print (os.listdir('\\\\piyushtech\techtech$\Piyush\Optimized Version'))
  • print (os.listdir('\\\\piyushtech/techtech$/Piyush/优化版'))
  • print (os.listdir('/piyushtech/techtech$/Piyush/优化版'))

没有任何作用。

请您参考如下方法:

仅供引用,以下适合我

os.listdir('//piyushtech/techtech$/Piyush/Optimized Version') 

如果您使用的是 python3,最好的方法是:-

from pathlib import Path 
Path("\\piyushtech\techtech$\Piyush\Optimized Version") 

参见 this