【发布时间】:2020-09-27 13:55:29
【问题描述】:
我在 Google Colab 中上传文本文件时遇到问题。
这里是代码
def load_doc(filename):
# Opening the file as read only
file = open(filename, 'r')
text = file.read()
file.close()
filename = (r'C:\Semicolon\ImageCaptionGenerator\Flickr8k_text\Flickr8k.token.txt')
doc = load_doc(filename)
保存到变量文件名中的文件路径是直接从我的系统中提取的。因此,我确信这没有问题,并且文件夹中存在 Flickr8k.token.txt。
这是不断弹出的错误。我尝试使用不同的方法读取不同的文本文件,但一直收到此错误。
FileNotFoundError Traceback (most recent call last)
<ipython-input-26-0d5546a08ca7> in <module>()
5 file.close()
6 filename = (r'C:\Semicolon\ImageCaptionGenerator\Flickr8k_text\Flickr8k.token.txt')
----> 7 doc = load_doc(filename)
<ipython-input-26-0d5546a08ca7> in load_doc(filename)
1 def load_doc(filename):
2 # Opening the file as read only
----> 3 file = open(filename, 'r')
4 text = file.read()
5 file.close()
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Semicolon\\ImageCaptionGenerator\\Flickr8k_text\\Flickr8k.token.txt'
我能做些什么来完成这项工作。这是我第一次在 Google Colab 中上传文本文件。请帮忙
【问题讨论】:
标签: python machine-learning data-science google-colaboratory