You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
256 B

import urllib.parse
def url_encode(s):
"""将字符串转化为URL编码"""
return urllib.parse.quote(s, safe='')
# 示例
input_string = input("请输入要编码的字符串:")
encoded_string = url_encode(input_string)
print(encoded_string)