本文共 1644 字,大约阅读时间需要 5 分钟。
?????????????HTML????????????????Windows 7???Python 3.5.2??????????????
????<??>string<??>???????string???????????
import rep = re.compile(r'(.*) ')matchp = p.search("positive ")if matchp: print(matchp.group(1)) # ???? print(matchp.group(0)) # ?????
???????matchp.group(1) ???? "positive"?? matchp.group(0) ?????????
???????????
???????HTML????????????????????????
?????<??>string<??>???????string???????????
import rep = re.compile(r'(.*) ')matchp = p.search("positive ")if matchp: print(matchp.group(1)) # ???? print(matchp.group(0)) # ?????
???????matchp.group(1) ???? "positive"?? matchp.group(0) ?????????
???????????
?????
???????HTML???????????????????????????????????????????????????????
import rep = re.compile(r'(.*) ')matchp = p.search("positive ")if matchp: print(matchp.group(1)) # ???? print(matchp.group(0)) # ?????
?????
positivepositive
???
matchp.group(1) ???? "positive"??????????????matchp.group(0) ????????????????????????????????????
?????
???????????????????????????????? .* ??????????????????????????HTML??????? <div> ???????????????????
????????????????
import rep = re.compile(r'(.*?) ', re.DOTALL)matchp = p.search("positive ")if matchp: print(matchp.group(1)) # ??????????
????????? r'<polarity>(.*?)</polarity>' ??? re.DOTALL flag??? . ????????????????????????????????
???
??????????????????????????????????????????????????????
转载地址:http://bszc.baihongyu.com/