相关疑难解决方法(0)

"u"和"r"字符串标志究竟做了什么,以及什么是原始字符串文字?

在问这个问题时,我意识到我对原始字符串知之甚少.对于那些自称是Django训练师的人来说,这很糟糕.

我知道编码是什么,而且我知道u''自从我得到什么是Unicode以来我们独自做了什么.

  • 但到底r''做了什么呢?它会产生什么样的字符串?

  • And above all, what the heck does ur'' do?

  • Finally, is there any reliable way to go back from a Unicode string to a simple raw string?

  • Ah, and by the way, if your system and your text editor charset are set to UTF-8, does u'' actually do anything?

python unicode python-2.x rawstring

600
推荐指数
7
解决办法
41万
查看次数

在BeautifulSoup中匹配id

我正在使用BeautifulSoup - python模块.我必须找到任何对id的引用,例如:'post-#'.例如:

<div id="post-45">...</div>
<div id="post-334">...</div>
Run Code Online (Sandbox Code Playgroud)

我该如何过滤?

html = '<div id="post-45">...</div> <div id="post-334">...</div>'
soupHandler = BeautifulSoup(html)
print soupHandler.findAll('div', id='post-*')
Run Code Online (Sandbox Code Playgroud)

python beautifulsoup

23
推荐指数
2
解决办法
2万
查看次数

标签 统计

python ×2

beautifulsoup ×1

python-2.x ×1

rawstring ×1

unicode ×1