aio-libs / aio-libs/yarl

Question: how could I join to URL list path parts?

未關閉
#138 11 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
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 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。