本文整理汇总了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)