如何用Python3的format方法构建URL字符串?
- 内容介绍
- 文章标签
- 相关推荐
本文共计86个文字,预计阅读时间需要1分钟。
使用Python 3中的`format`函数拼接URL,示例代码如下:
pythonurl=http://example.com/{path}/{filename}formatted_url=url.format(path=images, filename=photo.jpg)print(formatted_url)
python3 使用format函数对URL进行拼接
# 完整的urlurl = 'www.aliexpress.com/item/1215121315.html'
# 尝试拼接
url = 'www.aliexpress.com/item/-/{}.html'.format(1215121315)
print(url)
www.aliexpress.com/item/-/1215121315.html
本文共计86个文字,预计阅读时间需要1分钟。
使用Python 3中的`format`函数拼接URL,示例代码如下:
pythonurl=http://example.com/{path}/{filename}formatted_url=url.format(path=images, filename=photo.jpg)print(formatted_url)
python3 使用format函数对URL进行拼接
# 完整的urlurl = 'www.aliexpress.com/item/1215121315.html'
# 尝试拼接
url = 'www.aliexpress.com/item/-/{}.html'.format(1215121315)
print(url)
www.aliexpress.com/item/-/1215121315.html

