Python/pathlib/PurePath/drive

من موسوعة حسوب
< Python‏ | pathlib‏ | PurePath
اذهب إلى التنقل اذهب إلى البحث

المتغير PurePath.drive

سلسلة نصية تمثل اسم السواقة أو الحرف الممثل لها (في حال وجوده ضمن المسار)

>>> PureWindowsPath('c:/Program Files/').drive
'c:'

>>> PureWindowsPath('/Program Files/').drive
''

>>> PurePosixPath('/etc').drive
''

كما يتم يتم اعتبار مجلدات UNC المشارَكةاسمًا للسواقة

>>> PureWindowsPath('//host/share/foo.txt').drive
'\\\\host\\share'

===المتغير <code>PurePath.root</code>===
سلسلة نصية تمثل مسار الجذر (المحلي أو العام) في حال وجوده ضمن المسار

<syntaxhighlight lang="python3">
>>> PureWindowsPath('c:/Program Files/').root
'\\'
>>> PureWindowsPath('c:Program Files/').root
>>> PurePosixPath('/etc').root
'/'

UNC shares always have a root:

>>> PureWindowsPath('//host/share').root
'\\'