Python Language os.path Join Paths

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


To join two or more path components together, firstly import os module of python and then use following:

import os
os.path.join('a', 'b', 'c')

The advantage of using os.path is that it allows code to remain compatible over all operating systems, as this uses the separator appropriate for the platform it's running on.

For example, the result of this command on Windows will be:

>>> os.path.join('a', 'b', 'c')

In an Unix OS:

>>> os.path.join('a', 'b', 'c')

Got any Python Language Question?