Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
BeautifulSoup将中断转换为python换行符_Python_Python 3.x_Pandas_Beautifulsoup_Newline - Fatal编程技术网

BeautifulSoup将中断转换为python换行符

BeautifulSoup将中断转换为python换行符,python,python-3.x,pandas,beautifulsoup,newline,Python,Python 3.x,Pandas,Beautifulsoup,Newline,我有一个html表格,每个单元格有多行文本和数据,我试图最终提取这些表格,它们使用中断符,以便从网站中获取可读性。 以下是一个此类单元的示例: -21%1 500112% 您可以将'br'替换为'\n': for linebreak in soup.find_all('br'): linebreak.replace_with('\n') 希望对您有所帮助。您可以将'br'替换为'\n': for linebreak in soup.find_all('br'): linebre

我有一个html表格,每个单元格有多行文本和数据,我试图最终提取这些表格,它们使用中断符,以便从网站中获取可读性。 以下是一个此类单元的示例:
-
21%
1
5001
12%
您可以将
'br'
替换为
'\n'

for linebreak in soup.find_all('br'):
    linebreak.replace_with('\n')

希望对您有所帮助。

您可以将
'br'
替换为
'\n'

for linebreak in soup.find_all('br'):
    linebreak.replace_with('\n')

希望有帮助。

你想把整个字符串放在一个Pandas单元格中吗?我必须将每个单元格中的某些行与其他行进行匹配,因此我认为这一部分可能更容易处理,例如Pandasy中的爆炸。你想把整个字符串放在一个Pandas单元格中吗?我必须将每个单元格中的某些行与其他行进行匹配,因此我认为这一部分可能更容易处理在pandas中更容易处理像爆炸这样的事情当我尝试这个方法时,我确实在新行中获得了字符串,但导入pandas(通过read_html)删除了所有的换行符当我尝试这个方法时,我确实在新行中获得了字符串,但导入pandas(通过read_html)删除了所有的换行符