Answers for "python3 define path"

1

python how to open a file in a different directory in mac

import os
f = open (os.path.expanduser("~/Desktop/somedir/somefile.txt"))
Posted by: Guest on August-16-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

Python Answers by Framework

Browse Popular Code Answers by Language