【发布时间】:2023-02-25 01:19:47
【问题描述】:
需要一些建议
我正在使用 Python 和 Selenium 抓取一个网站。报废结果正在保存到 CSV 文件中。
我目前正在抓取一家公司的地址,但是返回的地址正以以下格式传递到一个单元格中;
Catalyst Inc\nBay Road\nLondonderry\nCounty Londonderry\nBT48 7TG\nBT 4 8 7 T G\nUNITED KINGDOM
我已经实现了以下 sn-p,它删除了“空白”的“\n”
df['full_address'] = df['full_address'].replace(r'\n',' ', regex=True)
将地址重新格式化为这种格式。
Catalyst Inc Bay Road Londonderry County Londonderry BT48 7TG B 4 8 7 T G UNITED KINGDOM
但是,我只是想知道是否有一种方法可以让地址仍然重新调入一个单元格,但格式为 ;
Catalyst Inc
Bay Road
Londonderry
County Londonderry
BT48 7TG
B T 4 8 7 T G
UNITED KINGDOM
【问题讨论】: