
本次代码运行使用jupyter notebook(anaconda) python 3.9.13安装python第三方库pyshortenersURL长转短输入待转换的URL运行代码实现URL转短输出结果为短链接短链接还原出长链接步骤1运行代码成功安装pip install pyshorteners步骤2试运行代码成功后可替换待转换url再次运行#长链接转短使用tinyurl from pyshorteners import Shortener short_engine Shortener() res short_engine.tinyurl.short(https://blog.csdn.net/hao20211228/article/details/128801798?csdn_share_tail%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22128801798%22%2C%22source%22%3A%22hao20211228%22%7D) print(res)运行代码结果截图步骤1短链接还原出长链接输入url短链接,运行代码可还原出原链接import requests url https://tinyurl.com/2kzqz9k7 res requests.head(url) print(res.headers.get(location))运行结果截图