python - Pyhton读取文件时为什么找不到文件?
PHPz
PHPz 2017-04-18 09:56:06
0
2
683

我想打开一个txt格式的文件并且想把每一行都输出出来,但是报错说:找不到文件,请教是什么问题。注:我看书说要把文件放在python所在的文件夹下面,这样做了发现并没有什么效果。

PHPz
PHPz

学习是最好的投资!

reply all(2)
左手右手慢动作

How do you run your code? Why is there the word python.exe on the console window? It is recommended that you add python to the path environment variable, and then go to your code folder to execute python testfile.py

大家讲道理

test.txt and testFile.py must be in the same folder. If they are not in the same folder, you need to write the absolute path.
Pay attention to how the windows and linux paths are written.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template