1、将网址中的字符串转化为人类可读的格式:
from urllib import parse
#将网址中的代表字符的东西转化成字符
urltostr=parse.unquote("%E8%AF%97%E8%AF%8D")
print(urltostr)
结果为:诗词
2、将人类可读的字符串转换成网址的格式:
from urllib import parse
strtourl=parse.quote("诗词")
print(strtourl)
结果为:%E8%AF%97%E8%AF%8D
1、将网址中的字符串转化为人类可读的格式:
from urllib import parse
#将网址中的代表字符的东西转化成字符
urltostr=parse.unquote("%E8%AF%97%E8%AF%8D")
print(urltostr)
结果为:诗词
2、将人类可读的字符串转换成网址的格式:
from urllib import parse
strtourl=parse.quote("诗词")
print(strtourl)
结果为:%E8%AF%97%E8%AF%8D