如何在生成的文本中一次读取一行请求?

时间:2018-01-03 18:07:51

标签: python python-requests

在Python 3中,我使用"固定宽度文件"来阅读链接。实施例

import requests
pagina = requests.get('http://idg.receita.fazenda.gov.br/orientacao/tributaria/cadastros/cadastro-nacional-de-pessoas-juridicas-cnpj/consultas/download/F.K03200UF.D71214AC')
only_text = pagina.text

only_text
'0107398403000180BOI GORDO AGROPECUARIA COMERCIO E REPRESENTACOES LTDA - EPP                                                                                                                   \n02073984030001802              49SELMA ELIANA MEDEIROS RIBEIRO                                                                                                                                \n02073984030001802              22MARCELO LUIZ SANCHES                                                                                                                                         \n0103173169000131CONSELHO ESCOLAR BOM JESUS                        

...

\n0129235225000109MD CONFECCOES EIRELI - ME                                                                                                                                                     \n02292352250001092              65MARCELO AMARO DA SILVA                                                                                                                                       \n'

我需要阅读" only_text"的每一行。分别在每一行的某些位置提取字符串

我试过这个,但命令一次只占一个字符而不是每一行

for linha in only_text:
    print(linha)

0
1
0
7
3
9
8
4
0
3
0
0
0
1
8
0
B
O
I
...

请问,如何分别隔离和读取每一行?

0 个答案:

没有答案