I would do
import os
path = os.path.normpath(path)
path.split(os.sep)
First normalize the path string into a proper string for the OS. Then os.sep
must be safe to use as a delimiter in string function split.
More Related Contents:
- “pip install unroll”: “python setup.py egg_info” failed with error code 1
- Freezing/Hanging tkinter GUI in waiting for the thread to complete
- Merge pandas dataframes where one value is between two others [duplicate]
- Lists in ConfigParser
- Reference list item by index within Django template?
- Python subprocess.Popen “OSError: [Errno 12] Cannot allocate memory”
- Can Flask have optional URL parameters?
- How to run python scripts using gimpfu from command line?
- How do I get the row count of a Pandas DataFrame?
- Unable to set default python version to python3 in ubuntu
- Selenium Webdriver: How to Download a PDF File with Python?
- Move Character with Vector
- Django formsets: make first required?
- Clustering text documents using scikit-learn kmeans in Python
- Google Groups API add Member
- Python ascii utf unicode
- What python libraries can tell me approximate location and time zone given an IP address?
- In matplotlib, how can I plot a multi-colored line, like a rainbow
- How can I schedule a Task to execute at a specific time using celery?
- how to pass parameters of a function when using timeit.Timer()
- Create new column based on values from other columns / apply a function of multiple columns, row-wise in Pandas
- Access is denied when trying to pip install a package on Windows
- I’m trying to use python in powershell
- Read .csv file from URL into Python 3.x – _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
- Grouped Bar graph Pandas
- About MySQLdb conn.autocommit(True)
- Sort list while pushing None values to the end
- how to save a pandas DataFrame to an excel file?
- Formatting floats in a numpy array [duplicate]
- Add density curve on the histogram