擅长:python、mysql、java
<p>如果需要原始版本,则需要<strong>取消引用中带有<code>%</code>的字符串</p>
<pre><code>from werkzeug import url_unquote
url_unquote('hi-martin%20king') # => 'hi-martin king'
</code></pre>
<p>现在有了无引号的字符串,可以用连字符或下划线替换空格</p>
<pre><code>replace_character = '-'
def fix_string(s):
return s.replace(' ', replace_character)
fix_string('hi-martin king') # => 'hi-martin-king'
</code></pre>