BUG[AssertionError]

首先,AssertionError表示代码中的assert语句,其后面的条件是错误的,遇到这个错误检查一下bug追踪到的assert语句。

我的错误:代码中,assert os.path.exist(path='../data/train'),路径错误,因此报错。

补充:

path = r'data\wikitext-103'
print(os.path.exists(path)
print(os.path.abspath('../data/wikitext-103'))  # 返回绝对路径
print(os.path.abspath(path)) 

print(os.getcwd()) # 当前工作空间绝对路径,也就是文件所属的最近一层文件夹的绝对路径
print(os.path.join(path, 'train.txt')) # 路径拼接

你可能感兴趣的:(异常,bug,python)