以下のように「os.open()」を使用してファイルを開こうとしています
>>> filePath
'C:\\Shashidhar\\text.csv'
>>> fd = os.open(filePath,os.O_CREAT)
>>> with os.fdopen(fd, 'w') as myfile:
... myfile.write("hello")
IOError: [Errno 9] Bad file descriptor
>>>
接続を自動的に閉じることができるように、「with」を使用して os.fdopen からファイルオブジェクトを開く方法はありますか?
ありがとう