[英]FileNotFoundError: [Errno 2] No such file or directory in Pycharm
I'm pretty new with Python and finding some issues on a trivial code.我对 Python 很陌生,并且在一些琐碎的代码上发现了一些问题。 I'm using Pycharm together with Anaconda.
我将 Pycharm 与 Anaconda 一起使用。
This is my code:这是我的代码:
posSentences = open('rt-polarity-pos.txt', 'r')
print (posSentences.read())
There is no issue in reading the file and printing it out when running it/terminal.在运行它/终端时读取文件并打印出来没有问题。
But when I try to run the same command in the console I get:但是当我尝试在控制台中运行相同的命令时,我得到:
FileNotFoundError: [Errno 2] No such file or directory
I so checked the directories of the console, but they seem fine and are the same of the running file:我因此检查了控制台的目录,但它们看起来很好并且与正在运行的文件相同:
Thank you for your help!谢谢您的帮助!
Python 解释器从Desktop\textan
运行,但文件位于Desktop\textan\textan\
目录中,因此 python 代码中文件的路径变为textan\rt...txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.