[英]Where does the \n come from?
I'm trying to test a string. 我正在尝试测试一个字符串。 I get the innerHTML, yet it has extra
u'\\n
and \\n'
我得到了innerHTML,但是它有额外的
u'\\n
和\\n'
AssertionError: u'\n<p><strong>Codul de Utilizator/Parola introduse nu sunt corecte!</strong></p>\n' != '<p><strong>Codul de Utilizator/Parola introduse nu sunt corecte!</strong></p>'
HTML from site 来自网站的HTML
<div id="errorDiv1" class="error" style="display: block;">
<p><strong>Codul de Utilizator/Codul introduse nu sunt corecte!</strong></p>
</div>
Code 码
error = self.driver.find_element_by_id("errorDiv1").get_attribute('innerHTML')
expected_error = '<p><strong>Codul de Utilizator/Parola introduse nu sunt corecte!</strong></p>'
self.assertEqual(error, expected_error)
What is happening here? 这是怎么回事 Where they come from?
他们来自哪里?
\\n
is the new line character. \\n
是换行符。
It's present since there's a new line character between line 1 and line 2 of your HTML code. 之所以存在,是因为HTML代码的第1行和第2行之间有换行符。
u''
defines a Unicode String in python Unicode Strings . u''
在python Unicode Strings中定义了Unicode String。
'\\n'
is a escape sequence and stands for Linefeed . '\\n'
是一个转义序列,代表Linefeed 。 Linefeed means advancing the printing area by one line. 换行意味着将打印区域前进一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.