os.path.sep
is the character used by the operating system to separate pathname components.
But when os.path.sep
is used in os.path.join()
, why does it truncate the path?
Example:
Instead of 'home/python'
, os.path.join
returns '/python'
:
>>> import os
>>> os.path.join('home', os.path.sep, 'python')
'/python'
I know that os.path.join()
inserts the directory separator implicitly.
Where is os.path.sep
useful? Why does it truncate the path?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…