Получите WD в Python
import os
path = os.getcwd()
print(path)
# /Users/mbp/Documents/my-project/python-snippets/notebook
print(type(path))
# <class 'str'>
Happy Hawk
import os
path = os.getcwd()
print(path)
# /Users/mbp/Documents/my-project/python-snippets/notebook
print(type(path))
# <class 'str'>
import os
os.path.dirname(os.path.abspath(__file__))
import os
print(os.getcwd())
import os
os.path.abspath(os.getcwd())
import os
files = os.listdir('.')
print(files)
for file in files:
# do something
>>> import os
>>> os.getcwd()
'C:\\Program Files\\PyScripter'
>>> os.getcwdb()
b'C:\\Program Files\\PyScripter'