s3 urls - get bucket name and path : <p>I have a variable which has the aws s3 url </p>

<pre><code>s3://bucket_name/folder1/folder2/file1.json
</code></pre>

<p>I want to get the bucket_name in a variables and rest i.e /folder1/folder2/file1.json in another variable. I tried the regular expressions and could get the bucket_name like below, not sure if there is a better way.</p>

<pre><code>m = re.search('(?&lt;=s3:\/\/)[^\/]+', 's3://bucket_name/folder1/folder2/file1.json')
print(m.group(0))
</code></pre>

<p>How do I get the rest i.e  - folder1/folder2/file1.json ?</p>

<p>I have checked if there is a boto3 feature to extract the bucket_name and key from the url, but couldn't find it.</p>
