【问题标题】:csv writer issue in Python - how can i remove these elements?Python 中的 csv writer 问题 - 我如何删除这些元素?
【发布时间】:2022-06-10 21:17:59
【问题描述】:

我正在从网站上抓取这些数据:

title: A title
Description: A description with, a comma.

我的代码是:

rows = title, desc   

with open('\scrape.csv', 'a', encoding='UTF8', newline='') as f:
    writer = csv.writer(f, delimiter='|', quoting=csv.QUOTE_NONE, escapechar='\\')
    writer.writerow([rows])

预期结果:

A title | A description with, a comma.

但我得到的结果:

('A title', \"A description with, a comma.\")

为什么会忽略分隔符?为什么我得到括号中的结果?我可以摆脱escapechar='\\'吗?

【问题讨论】:

  • 你在哪里看到这个结果?
  • 什么是rows? (如果您打印它,您会得到什么确切?)

标签: python


猜你喜欢
  • 2010-11-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-25
  • 1970-01-01
  • 2010-10-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多