os.path.isdir(path) then get path code example
Example: python os.path.isdir exception
import os
if os.path.isdir(root_folder):
print('Ok')
else:
print('Nok')
import os
if os.path.isdir(root_folder):
print('Ok')
else:
print('Nok')