Monday, July 5, 2021

How to Specify Directory for Windows in Python Program

 

you can use always:

'C:/mydir'

this works both in linux and windows. Other posibility is

'C:\\mydir'

if you have problems with some names you can also try raw string literals:

r'C:\mydir'

however best practice is to use the os.path module functions that always select the correct configuration for your OS:

os.path.join(mydir, myfile)

No comments:

Post a Comment

Linux Kernel Compilation

 Step 1: Install Required Packages Install additional packages before building a kernel. To do so, run this command: sudo apt-get install gi...