Python 3.6 解決"PermissionError: [Errno 13] Permission denied"

NO IMAGE

環境:

    win7 Python3.6

輸入:

file = open('E:/我的堅果雲/Pycharmprojects/Laboratory','w')
file.write('Hello world!')

問題:

Traceback (most recent call last):
File "E:\我的堅果雲\PycharmProjects\Windows\1_print_open.py", line 1, in <module>
file = open('E:/我的堅果雲/Pycharmprojects/Laboratory','w')
PermissionError: [Errno 13] Permission denied: 'E:/我的堅果雲/Pycharmprojects/Laboratory'

解決:

 file = open('E:/我的堅果雲/Pycharmprojects/Laboratory','w')

這裡寫入的是資料夾 ` /Laboratory ` ,而不是檔案,所以應該在後面加一個檔案,即:

 file = open('E:/我的堅果雲/Pycharmprojects/Laboratory/1.txt','w')

這樣這個路徑下就會生成一個 `1.txt` 的檔案,檔案內容是 

Hello world!