I am trying to access a path starting with ~/ in linux using python and its not working. Tried getting absolute path but that also is failing for ~/paths. What is the right way to handle ~/path in python?
mkdir ~/mnt
touch ~/mnt/test.txt
ls ~/mnt
Results:
test.txt
python3
import os
import subprocess
print(os.path.exists('~/mnt'))
print(os.path.exists(os.path.abspath('~/mnt')))
subprocess.call('ls ~/mnt3', shell=True)
Results in,
False
False
test.txt
0