本文整理汇总了Python中os.path.altsep方法的典型用法代码示例。如果您正苦于以下问题:Python path.altsep方法的具体用法?Python path.altsep怎么用?Python path.altsep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os.path
的用法示例。
在下文中一共展示了path.altsep方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: split_template_path
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import altsep [as 别名]
def split_template_path(template):
"""Split a path into segments and perform a sanity check. If it detects
'..' in the path it will raise a `TemplateNotFound` error.
"""
pieces = []
for piece in template.split('/'):
if path.sep in piece \
or (path.altsep and path.altsep in piece) or \
piece == path.pardir:
raise TemplateNotFound(template)
elif piece and piece != '.':
pieces.append(piece)
return pieces
示例2: split_template_path
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import altsep [as 别名]
def split_template_path(template):
"""Split a path into segments and perform a sanity check. If it detects
'..' in the path it will raise a `TemplateNotFound` error.
"""
pieces = []
for piece in template.split("/"):
if (
path.sep in piece
or (path.altsep and path.altsep in piece)
or piece == path.pardir
):
raise TemplateNotFound(template)
elif piece and piece != ".":
pieces.append(piece)
return pieces
示例3: secure_filename
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import altsep [as 别名]
def secure_filename(filename):
for sep in path.sep, path.altsep:
if sep:
filename = filename.replace(sep, ' ')
filename = str(_filename_ascii_strip_re.sub('', '_'.join(
filename.split()))).strip('._')
return filename