本文整理匯總了Python中os.path.lstrip方法的典型用法代碼示例。如果您正苦於以下問題:Python path.lstrip方法的具體用法?Python path.lstrip怎麽用?Python path.lstrip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類os.path
的用法示例。
在下文中一共展示了path.lstrip方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_resource_url
# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import lstrip [as 別名]
def test_resource_url():
"""Test resource_url() which can be used from templates."""
data = jinja.render('test2.html')
print(data)
url = QUrl(data)
assert url.isValid()
assert url.scheme() == 'file'
path = url.path()
if utils.is_windows:
path = path.lstrip('/')
path = path.replace('/', os.sep)
with open(path, 'r', encoding='utf-8') as f:
assert f.read().splitlines()[0] == "Hello World!"
示例2: __init__
# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import lstrip [as 別名]
def __init__(self, url=None, *args, **kwargs):
# Works around an apparent Git bug
# (see http://article.gmane.org/gmane.comp.version-control.git/146500)
if url:
scheme, netloc, path, query, fragment = urlsplit(url)
if scheme.endswith('file'):
initial_slashes = path[:-len(path.lstrip('/'))]
newpath = (
initial_slashes +
urllib_request.url2pathname(path)
.replace('\\', '/').lstrip('/')
)
url = urlunsplit((scheme, netloc, newpath, query, fragment))
after_plus = scheme.find('+') + 1
url = scheme[:after_plus] + urlunsplit(
(scheme[after_plus:], netloc, newpath, query, fragment),
)
super(Git, self).__init__(url, *args, **kwargs)
示例3: __init__
# 需要導入模塊: from os import path [as 別名]
# 或者: from os.path import lstrip [as 別名]
def __init__(self, url=None, *args, **kwargs):
# Works around an apparent Git bug
# (see https://article.gmane.org/gmane.comp.version-control.git/146500)
if url:
scheme, netloc, path, query, fragment = urlsplit(url)
if scheme.endswith('file'):
initial_slashes = path[:-len(path.lstrip('/'))]
newpath = (
initial_slashes +
urllib_request.url2pathname(path)
.replace('\\', '/').lstrip('/')
)
url = urlunsplit((scheme, netloc, newpath, query, fragment))
after_plus = scheme.find('+') + 1
url = scheme[:after_plus] + urlunsplit(
(scheme[after_plus:], netloc, newpath, query, fragment),
)
super(Git, self).__init__(url, *args, **kwargs)