我试图拆分python中的字符串unicode组合。必须在从网站检索到的ResultSet对象上进行拆分。使用下面的代码,我能得到的细节,实际上它是用户的详细信息:拆分字符串,unicode,unicode,python中的字符串
from bs4 import BeautifulSoup
import urllib2
import re
url = "http://www.mouthshut.com/vinay_beriwal"
profile_user = urllib2.urlopen(url)
profile_soup = BeautifulSoup(profile_user.read())
usr_dtls = profile_soup.find("div",id=re.compile("_divAboutMe")).find_all('p')
for dt in usr_dtls:
usr_dtls = " ".join(dt.text.split())
print(usr_dtls)
的输出如下:
i love yellow..
Name: Vinay Beriwal
Age: 39 years
Hometown: New Delhi, India
Country: India
Member since: Feb 11, 2016
我需要的是创造不同的5个变量的名称,年龄,家乡,国家,成员自,并在':'之后存储相应的值。
感谢