Python win10 open函数一直显示路径不存在
各位大神,
帮忙看看这个报错是什么问题,windows,试过各种路径写法都不行
def test_create(name,msg):
desktop_path = 'C://user/Ryan/Desktop/'
full_path = desktop_path+name+'.txt'
file = open(full_path,'w')
file.write(msg)
file.close()
print('Done')
test_create('hello','hello,ryan')
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-7-bac9aeb8aa6d> in <module>()
7 print('Done')
8
----> 9 test_create('hello','hello,ryan')
<ipython-input-7-bac9aeb8aa6d> in test_create(name, msg)
2 desktop_path = 'C://user/Ryan/Desktop/'
3 full_path = desktop_path+name+'.txt'
----> 4 file = open(full_path,'w')
5 file.write(msg)
6 file.close()
FileNotFoundError: [Errno 2] No such file or directory: 'C://user/Ryan/Desktop/hello.txt'