<jupyter_start><jupyter_text>```jsescape("春节")// "%u6625%u8282"escape("A B")// "A%20B"```<jupyter_code>import sys
import json
import pprint
from urllib import parse
print(1, parse.quote('推荐'))

print(2, sys.getdefaultencoding())

print(3, u'%E6%8E%A8%E8%8D%90'.encode('gb2312'))

print(4, parse.unquote('%E6%8E%A8%E8%8D%90'))

print(5, parse.unquote_plus('1+2'))

print(6, parse.unquote('1+2'))

from urllib import parse

url = r'https://docs.python.org/3.5/search.html?q=parse&check_keywords=yes&area=default'

print(1, parse.urlparse(url))
# ParseResult(scheme='https', netloc='docs.python.org', path='/3.5/search.html', params='', query='q=parse&check_keywords=yes&area=default', fragment='')

param: dict = parse.parse_qs(parse.urlparse(url).query)
print(2, param)
print(2, param['q'][0])

print(3, parse.parse_qs('proxy=172.16.17.32:8080&task=XXXXX|5-3+2'))
print(3, parse.parse_qs('action=addblog&job=modify&tid=1766670'))
print(3, parse.parse_qsl('action=addblog&job=modify&tid=1766670'))

link = 'id%253D184ff84d27c3613d%26quality%3Dmedium'

print(1, parse.unquote(parse.unquote(link)))
print(2, parse.unquote(link))

print(3, parse.urlencode({'name': 'walker', 'age': 99, }))
print(3, parse.quote('a&b/c'))
print(3, parse.quote_plus('a&b/c'))<jupyter_output>1 id=184ff84d27c3613d&quality=medium
2 id%3D184ff84d27c3613d&quality=medium
3 name=walker&age=99
3 a%26b/c
3 a%26b%2Fc
{'fraction_non_alphanumeric': 0.21155234657039712, 'fraction_numerical': 0.09963898916967509, 'mean_word_length': 9.043478260869565, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '599761', 'license': 'MIT', 'n_tokens_mistral': 662, 'n_tokens_neox': 610, 'n_words': 76, 'path': '_note_/内置包/parse_文件编码_网页url处理.ipynb', 'repo_name': 'By2048/_python_', 'size': '1388'}