跳转到主要内容

用于从字符串两侧删除字符的函数形式。

项目描述

remove_hairs

https://badge.fury.io/py/remove_hairs.png https://pypip.in/d/remove_hairs/badge.png

用于从字符串两侧删除字符的函数形式。

文档

仅有一个函数 remove_hairs() 和一个装饰器 remove_hairs_decorator()

remove_hairs()

当您有字符串并需要从字符串两侧删除一些字符时,此函数非常有用。

>>> from remove_hairs import remove_hairs
>>> remove_hairs(",a-sd,-/")
'a-sd'

默认情况下,该函数使用在 .HAIRS 中定义的字符集,该字符集被定义为 /:;,- []<>()。您可以使用 hairs 参数更改此设置

>>> remove_hairs(" - a sd: --", " -")
'a sd:'

remove_hairs_decorator()

正如其名所示,remove_hairs_decorator()remove_hairs() 的装饰器

@remove_hairs_decorator
def x():
    return ",a-sd,-/"

assert x() == "a-sd"

或者使用 hairs 参数

@remove_hairs_decorator(hairs=" -")
def y():
    return " - a sd: --"

assert y() == "a sd:"

安装

代码托管在 PYPI,您可以使用以下命令轻松安装

sudo pip install remove_hairs

测试

此项目使用 py.test 进行测试。只需从项目根目录运行 py.test

$ py.test
============================= test session starts ==============================
platform linux2 -- Python 2.7.6 -- py-1.4.26 -- pytest-2.6.4
collected 2 items

tests/test_remove_hairs.py ..

=========================== 2 passed in 0.02 seconds ===========================

变更日志

1.0.1

  • 修复了 setup.py

1.0.0

  • 项目创建。

项目详情


下载文件

下载适合您平台的应用程序。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。

源代码分发

remove_hairs-1.0.1.tar.gz (4.1 kB 查看哈希值)

上传时间 源代码

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面