python3中的相对路径问题

1、需要手动将Edit configurations中work path设置为当前py文件所在目录。

test.py

with open('1.txt') as f:
	f.write('当前目录‘)
	f.close()
# ./2.txt 当前目录
# ../3.txt  上级目录

猜你喜欢

转载自blog.csdn.net/angel_hben/article/details/89355432