Question: how could I join to URL list path parts?
未關閉
question
- 主要語言
- Python
- 星號
- 1.5k
- 分支
- 215
- 平均合併
- 1 天 2 分鐘
- 30 天內合併 PR
- 13
描述
Assume I have an URL `URL('http://localhost:5984/base')` and some list of path segments like `['foo', '/bar', 'baz%']`. What's the proper way to join them to url to have`URL(http://localhost:5984/base/foo/%2fbar/baz%25)` as result?
So far I came to:
```
url = URL('http://localhost:5984/base')
segments = ['foo', '/bar', 'baz%']
for seg in sements:
url /= seg.replace('/', '%2F')
```
But that doesn't looks like good solution. Or it does?
貢獻指南
評估
這個 Issue 還沒有評估資料。