Answers for "path handling in file handilng in python"

1

python file location path

import os

print('getcwd:      ', os.getcwd())
print('__file__:    ', __file__)
Posted by: Guest on August-23-2020
0

pathlib path forward or back slahses

>>> import pathlib
>>> p = pathlib.PureWindowsPath(r'diranotherdirfoodirmore')
>>> print(p)    
diranotherdirfoodirmore
>>> print(p.as_posix())
/dir/anotherdir/foodir/more
>>> str(p)
'\dir\anotherdir\foodir\more'
>>> str(p.as_posix())
'/dir/anotherdir/foodir/more'
Posted by: Guest on November-09-2020

Code answers related to "path handling in file handilng in python"

Python Answers by Framework

Browse Popular Code Answers by Language