我有这个字符串,基本上是一些html
<acronym class="non-experimental-qualifier" title="Indicates that the information given is not based on experimental findings." onclick="dialog('non_experimental_qualifiers'); Event.stop(event || window.event); return false" onmousedown="Event.stop(event || window.event);">By similarity</acronym>. <a class="attribution" href="http://hamap.expasy.org/unirule/
无论如何,我可以在python中将其读取为字符串。。。通常它只有一种类型的'或',所以我可以用另一种类型对其进行字符串设置,但是。
如何将其转换为字符串?喜欢:
html = '<acronym class="non-experimental-qualifier" title="Indicates that the information given is not based on experimental findings." onclick="dialog('non_experimental_qualifiers'); Event.stop(event || window.event); return false" onmousedown="Event.stop(event || window.event);">By similarity</acronym>. <a class="attribution" href="http://hamap.expasy.org/unirule/'
您可以使用三引号引起来的字符串:
html = '''<acronym class="non-experimental-qualifier" title="Indicates that the information given is not based on experimental findings." onclick="dialog('non_experimental_qualifiers'); Event.stop(event || window.event); return false" onmousedown="Event.stop(event || window.event);">By similarity</acronym>. <a class="attribution" href="http://hamap.expasy.org/unirule/'''
下面是一个演示:
>>> mystr = '''It's a "string"'''
>>> mystr
'It\'s a "string"'
>>>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句