擅长:python、mysql、java
<p>你的第一个字符串似乎有些问题。我不太清楚为什么会有这么多的空字符(<code>\x00</code>),但不管怎样,我们都可以编写一个函数来清理这些字符:</p>
<pre><code>s_1 = '\x00"\x00i\x00t\x00i\x00n\x00e\x00r\x00a\x00r\x00y\x00_\x00o\x00p\x00t\x00i\x00o\x00n\x00s\x00_\x00s\x00e\x00a\x00r\x00c\x00h\x00_\x00b\x00u\x00t\x00t\x00o\x00n\x00"\x00 \x00=\x00 \x00"\x00L\x00a\x00u\x00n\x00c\x00h\x00 \x00t\x00h\x00e\x00 \x00s\x00e\x00a\x00r\x00c\x00h\x00"\x00;\x00'
s_2 = '"itinerary_options_search_button" = "Launch the search";'
def null_cleaner(string):
new_string = ""
for char in string:
if char != "\x00":
new_string += char
return new_string
print(null_cleaner(s_1) == null_cleaner(s_2))
</code></pre>
<p>一种不那么健壮的方法是简单地拼接字符串以删除其他字符(恰好是<code>\x00</code>):</p>
^{pr2}$