简体   繁体   English

OSError: [Errno 9] 错误的文件描述符 python 3.7 CSV 写入器

[英]OSError: [Errno 9] Bad file descriptor python 3.7 CSV writer

I am trying to write data into csv file.我正在尝试将数据写入 csv 文件。 I am using python 3.7 64-bit pycharm in Windows 10.我在 Windows 10 中使用 python 3.7 64 位 pycharm。

import csv
with open('test.csv', 'w', newline='') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=' ',
                        quotechar='|', quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])

Getting that error得到那个错误

C:\Users\Ehtisham\venv\Scripts\python.exe C:/Users/Ehtisham/Documents/Python/OLX/test.py OSError: [Errno 9] Bad file descriptor C:\Users\Ehtisham\venv\Scripts\python.exe C:/Users/Ehtisham/Documents/Python/OLX/test.py OSError: [Errno 9] 文件描述符错误

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last): File "C:/Users/Ehtisham/Documents/Python/OLX/test.py", line 6, in spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])回溯(最近一次通话最后):文件“C:/Users/Ehtisham/Documents/Python/OLX/test.py”,第 6 行,在 spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam' ])

OSError: [Errno 9] Bad file descriptor OSError: [Errno 9] 错误的文件描述符

I have change my project loaction its works smoothly.我已经顺利地改变了我的项目位置。 In Window 10 creating problem by Windows Defender.在 Window 10 中,Windows Defender 产生了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM