我创建一个pi.txt的文件,用以下代码读取:
with open("pi.txt") as test_file:
number = test_file.read()
print(number)
FileNotFoundError: [Errno 2] No such file or directory: 'pi.txt'
想了很久试过很多方法都解决不了,请大神帮忙看看,卡在这里跨不去啊
如果我将程序改为
with open("first/pi.txt") as test_file:
number = test_file.read()
print(number)
就可以
txt文件和py文件都是在同一路径下的