aio-libs / aio-libs/yarl

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

オープン
#138 コメント 11 件 リアクション 1 件 担当者 0 名 GitHub で見る
question
主要言語
Python
スター
1.5k
フォーク
215
平均マージ
1日 2分
マージ済み PR(30日)
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 を短くまとめたダイジェスト。