使用urlib.parse 中的模块对url进行编码
from urllib import parse
parse.quote(‘a&b/c’) #未编码斜线
‘a%26b/c’
parse.quote_plus(‘a&b/c’) #编码了斜线
‘a%26b%2Fc’
下面未编码斜线部分
import requests
from urllib.parse import quote
prefix = 'https://geojson.io/#data=data:text/x-url,{}'
url = quote('https://artifactory.momenta.works:443/artifactory/mdk-sample-data/2022/03/28/workdir/output/areas_discretized.json')
common_url = prefix.format(url)
print(common_url)