多行文字 [英] Text over multiple lines

查看:87
本文介绍了多行文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用HTMLParser来解析网页,这是我需要的例程的一部分

来写(我是Python的新手) )一旦我知道标签的开始和结束然后将标签之间的所有数据

分配给一个变量,这包括寻找一个特定的标签和

如果标签在同一行上开始和结束很容易,但是如果将它分成两行或更多行,那么我将怎么做?
< br $>
谢谢


R

解决方案

Rigga写道:
< blockquote class =post_quotes>我正在使用HTMLParser来解析一个网页,我需要编写的例程的一部分(我是Python的新手)涉及寻找一个特定的标签和
一旦我知道标签的开始和结束然后将标签之间的所有数据分配给变量,如果标签在同一行开始和结束,这很容易但是我怎么办呢这样做,如果它两条或更多条线分开?




也许你应该把整个文字粘在一条长线上?


-

Pawel Kraszewski FreeBSD / Linux

电子邮件/ Jabber电话ICQ GG
Pa ************** @ wp.pl +48 604 777447 45615564 69381



我需要写的例程(我是Python的新手)涉及寻找一个特定的标签和
一旦我知道标签的开始和结束然后分配所有的数据
在变量的标签之间,如果标签在同一行开始和结束,这很容易,但是如果它分成两行或更多行,我将如何去做?

谢谢

R




不要重新参与发泄轮,
http://www.crummy.com/software / BeautifulSoup /

-

Nigel Rowe

给垃圾邮件发送者的痘痘让我写下我的地址喜欢..

rho(蜗牛)swiftdsl(停止)com(停止)au


On Sun,2004年6月20日21:03:34 +1000,Nigel Rowe写道:

Rigga写道:



我正在使用HTMLParser来解析一个网页,我需要的一部分例程(我是Python的新手)涉及寻找一个特定的标签和
一旦我知道标签的开始和结束然后分配所有标签与变量之间的数据,如果标签在同一行上开始和结束,这很容易,但是如果它分开两个或多个,我该如何去做呢?线路?

谢谢

R



唐重新发明轮子,
http://www.crummy .com / software / BeautifulSoup /



我想手动完成,因为它有助于我理解Python,

任何想法如何我去了吗?


Hi,

I am using the HTMLParser to parse a web page, part of the routine I need
to write (I am new to Python) involves looking for a particular tag and
once I know the start and the end of the tag then to assign all the data
in between the tags to a variable, this is easy if the tag starts and ends
on the same line however how would I go about doing it if its split over
two or more lines?

Thanks

R

解决方案

Rigga wrote:

I am using the HTMLParser to parse a web page, part of the routine I need
to write (I am new to Python) involves looking for a particular tag and
once I know the start and the end of the tag then to assign all the data
in between the tags to a variable, this is easy if the tag starts and ends
on the same line however how would I go about doing it if its split over
two or more lines?



Perhaps you should glue the whole text as a one long line?

--
Pawel Kraszewski FreeBSD/Linux

E-Mail/Jabber Phone ICQ GG
Pa**************@wp.pl +48 604 777447 45615564 69381


Rigga wrote:

Hi,

I am using the HTMLParser to parse a web page, part of the routine I need
to write (I am new to Python) involves looking for a particular tag and
once I know the start and the end of the tag then to assign all the data
in between the tags to a variable, this is easy if the tag starts and ends
on the same line however how would I go about doing it if its split over
two or more lines?

Thanks

R



Don''t re-invent the wheel,
http://www.crummy.com/software/BeautifulSoup/

--
Nigel Rowe
A pox upon the spammers that make me write my address like..
rho (snail) swiftdsl (stop) com (stop) au


On Sun, 20 Jun 2004 21:03:34 +1000, Nigel Rowe wrote:

Rigga wrote:

Hi,

I am using the HTMLParser to parse a web page, part of the routine I need
to write (I am new to Python) involves looking for a particular tag and
once I know the start and the end of the tag then to assign all the data
in between the tags to a variable, this is easy if the tag starts and ends
on the same line however how would I go about doing it if its split over
two or more lines?

Thanks

R



Don''t re-invent the wheel,
http://www.crummy.com/software/BeautifulSoup/


I want to do it manually as it will help with my understanding of Python,
any ideas how I go about it?


这篇关于多行文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆