每当我尝试运行这段代码时,它都会给我一个IO错误

时间:2017-05-17 18:07:35

标签: python

def Save_hotels():

    global numberOfHotels
    global My_Hotels

    file = open('data.csv', "w", newline="\n")
    dataEX = csv.writer(file, delimiter=",")

    mylist = [numberOfHotels]
    dataEX.writerow(mylist)

    for hotel in My_Hotels:

        mylist = [hotel.ID,hotel.Name,hotel.Stars,hotel.Rooms]

        for i in hotel.Reservations:
            res = [i.Customer_Name,i.Date,i.Time]
            mylist.extend(res)

        dataEX.writerow(mylist)

    file.close()

这是错误:

File "D:/Python Projects/Domes Dedomenwn Project(2017)/Main.py", line 54, in 
Save_hotels
file = open('data.csv', "w", newline="\n")
PermissionError: [Errno 13] Permission denied: 'data.csv'

0 个答案:

没有答案