'I want to split the URL as mentioned in the description using python

URL = ftp://0.0.0.0/Engineering/Camera_Services/xxxxxx.x/QA_Release/zzzzzz_11-MAR-2022.zip

I want to split and add them to a variable like below

Expecting:

Custom Folder = Engineering/Camera_Services/xxxxxx.x/QA_Release
Filename = zzzzzz_11-MAR-2022.zip


Solution 1:[1]

URL = 'ftp://0.0.0.0/Engineering/Camera_Services/xxxxxx.x/QA_Release/zzzzzz_11-MAR-2022.zip'

Filename = URL.split("/")[-1]
Custom_Folder = "/".join(URL.split("/")[3:-1])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1