Visual studio Python web扫描停止工作-无效文件错误

Visual studio Python web扫描停止工作-无效文件错误,visual-studio,python-3.5,pickle,pathlib,Visual Studio,Python 3.5,Pickle,Pathlib,我一直在做一个网页抓取程序,它最近刚刚停止工作,并给我以下错误 Traceback (most recent call last): File "C:/Users/Bob/Desktop/test 3.5.py", line 7, in <module> with open(saveDB,'rb') as f: TypeError: invalid file: WindowsPath('Z:/project1/MasterWellDB.txt') 任

我一直在做一个网页抓取程序,它最近刚刚停止工作,并给我以下错误

Traceback (most recent call last):
  File "C:/Users/Bob/Desktop/test 3.5.py", line 7, in <module>
    with open(saveDB,'rb') as f:
TypeError: invalid file: WindowsPath('Z:/project1/MasterWellDB.txt')

任何帮助都将不胜感激。谢谢

不确定这是什么原因,但您正在为路径使用
/
\
分隔符。如果您在windows上,请使用
\
,否则请使用
/
。最上面的代码是自动生成的错误,我没有编写该代码。在我的代码中,我只使用了\,我只是尝试了使用/,但这并没有改变任何东西。为什么要在字符串中使用
r
前缀?(它通常代表regex)哦,谢谢!那我就没有其他线索了:/
from pathlib import Path
import pickle
# Opening well database
saveDB = Path(r"Z:\project1\MasterWellDB.txt")
#open picked DB if avaiable else remake database
if saveDB.exists():
    with open(saveDB,'rb') as f:
        wells = pickle.load(f)
        print('success!')