在python中写入CSV时,用引号和无引号编写空字符串
我从MySQL表获得的值可能为零值和空字符串。
但是,当我尝试使用csv.writer(file_path,Quording = csv.quote_nonnumeric)
将这些值写入CSV文件时,null值和空字符串都用引号编写。
我希望用引号和无引号编写的空字符串编写。
有什么方法可以在Python中实现这一目标?
I am getting values from MySQL table that can be NULL values and empty strings.
However when I am trying to write these values into a csv file using csv.writer(file_path, quoting=csv.QUOTE_NONNUMERIC)
, both NULL values and empty strings are written with quotes.
I would like the empty strings to be written with quotes and NULL values to be written without quotes.
Is there any way to achieve this in Python?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论