<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>编码解码 &#8211; from0to1</title>
	<atom:link href="https://www.from0to1.top/tag/%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81/feed" rel="self" type="application/rss+xml" />
	<link>https://www.from0to1.top</link>
	<description>一个研究技术、分享经验的博客</description>
	<lastBuildDate>Sun, 01 Oct 2023 16:49:57 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>
	<item>
		<title>利用python实现url编码和解码</title>
		<link>https://www.from0to1.top/224.html</link>
					<comments>https://www.from0to1.top/224.html#respond</comments>
		
		<dc:creator><![CDATA[雾朦Official]]></dc:creator>
		<pubDate>Sun, 01 Oct 2023 15:47:30 +0000</pubDate>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[编码解码]]></category>
		<guid isPermaLink="false">https://www.from0to1.top/?p=224</guid>

					<description><![CDATA[先看完整代码 import urllib.parse a = 0 while a not in [&#34;1&#34;, &#34;2&#34;]: a = input(&#34;请重新输入，url编码请按1，url解码请按下2&#34;) if a == &#34;1&#34;: b = input(&#34;输入你所要编码的字符&#34;) print(urllib.pa [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>先看完整代码</p>
<pre class="prettyprint linenums">import urllib.parse

a = 0
while a not in [&quot;1&quot;, &quot;2&quot;]:
    a = input(&quot;请重新输入，url编码请按1，url解码请按下2&quot;)

if a == &quot;1&quot;:
    b = input(&quot;输入你所要编码的字符&quot;)
    print(urllib.parse.quote(b))
else:
    b = input(&quot;请输入你所要解码的字符&quot;)
    print(urllib.parse.unquote(b))</pre>
<div class="link-title wow rollIn">思路</div>
<p>调用urllib.parse库</p>
<pre class="prettyprint linenums">import urllib.parse</pre>
<p>给a变量一个初始值，然后让使用者选择编码和解码，whlile循环让使用者输入的a的值只能是字符1或者2，否则就会一直循环</p>
<pre class="prettyprint linenums">while a not in [&quot;1&quot;, &quot;2&quot;]:
    a = input(&quot;请重新输入，url编码请按1，url解码请按下2&quot;)</pre>
<p>if判断使用者是需要编码操作还是解码操作，获得用户输入的值后用urllib.parse.unquote()或urllib.parse.quote()函数进行解码或编码操作</p>
<pre class="prettyprint linenums">if a == &quot;1&quot;:
    b = input(&quot;输入你所要编码的字符&quot;)
    print(urllib.parse.quote(b))
else:
    b = input(&quot;请输入你所要解码的字符&quot;)
    print(urllib.parse.unquote(b))</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.from0to1.top/224.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
