python中怎么从一个文本中截取某自己想要的字符后放到新的文本中,都再过节也不知道会不会被搭理

python中如何从一个文本中截取某自己想要的字符后放到新的文本中,都再过节也不知道会不会被搭理,在线等
“十.一”想要勉励一下,自己找了点资料学习一下python,看了点基础,记不住,于是乎想联系点东西,练习字符串的替换

import os
os.chdir('d:\\') 
if not os.path.exists('F1.txt'):
exit(-1) 
lines = open('F1.txt').readlines() 

rep = open('F2.txt','w') 

for s in lines:
rep.write( s.replace('nba','cba').replace('goon','close')) 
rep.close() 
写的简单了,呵呵呵,python中怎么从一个文本中截取某自己想要的字符后放到新的文本中,都再过节也不知道会不会被搭理写出来就开始得瑟了,想把某以文本的特定字符后的字符串截取出来,python中怎么从一个文本中截取某自己想要的字符后放到新的文本中,都再过节也不知道会不会被搭理python中怎么从一个文本中截取某自己想要的字符后放到新的文本中,都再过节也不知道会不会被搭理却无能为力了,找了个题目:京东的数字商品的音乐 http://music.jd.com/60059228.html 看了它的源代码 想把里面的歌曲名字取出来,
1.Falling Slowly(Steve Kazee)
2.My Love(Westlife)
.
.
.
python 源代码

------解决方案--------------------
使用正则表达式来做,python的模块re


#!/usr/bin/env python

import re
import urllib2

response = urllib2.urlopen('http://music.jd.com/60059228.html').read()

songs = re.findall('<td class="player-name" skuid="[0-9]+" s_name="([^"]+)" s_url="[^"]+" src="[^"]+">', response)

for song in songs:
    print song


输出:
Falling Slowly(Steve Kazee)
My Love(Westlife)
You Raise Me Up(Westlife)
The Show(Lenka)
Trouble Is A Friend(Lenka)
Makin Love Out of Nothing At All(Air Supply)
All Out of Love(Air Supply)
Eternal Flame(Suzanna Hoffs)
Moonlight Shadow(Groove Coverage)
Frosty The Snowman(Fiona Apple)
Auld Lang Syne(Buddy)
Love in December(Club 8)
Whataya Want From Me(Adam Lambert)
She Will Be Loved(Maroon 5)
The Story(Brandi Carlile)
That Year(Brandi Carlile)
Wasted(Brandi Carlile)
When You're Gone(Avril Lavigne)
Wish You Were Here(Avril Lavigne)
Leave Right Now(Will Young)
Jealousy(Will Young)
I Dreamed A Dream(Susan Boyle)
Mad World(Susan Boyle)
Memory(Susan Boyle)
Take Me Home,Country Roads(John Denver)
Jingle Bells(John Denver)
singer/songwriter(Egil Olsen)
Valder Fields(Tamas Wells)
Vendredi(Tamas Wells)
Blowin'In The Wind(Bob Dylan)
Knockin'On Heavens Door(Bob Dylan)
I Love You(Stewart Mac)
Someone Like You(Agapornis)
Rolling in the Deep (vocal version)(The Piano)
Firework (Glee Cast Version)(Glee Cast)
Teenage Dream (Glee Cast Version)(Glee Cast)
Poker Face(Meg Pfeiffer)
Call Me Maybe (Glee Cast Version)(Glee Cast)
Stronger(What Doesn't Kill You)(Kelly Clarkson)
Because Of You(Kelly Clarkson)
Just One Last Dance(Sarah Connor)
Living To Love You(Single Version)(Sarah Connor)
Christmas In My Heart(Sarah Connor)
Cry On My Shoulder(Overflow)
Marry You(Bruno Mars)
Set Fire To The Rain(Adele)
What Makes You Beautiful(单向乐队)
FucKin' Perfect(P!nk)
Get The Party Started(P!nk)
You Give Love A Bad Name(新声驾到)