跳转到主要内容

用于使用分隔符绑定字符串的函数

项目描述

Build Status

bind

版本 2.1.0

bind是一个我们经常需要的字符串连接函数

用法

from bind import bind
things_to_bind = ['castable', 'to', 's t r i n g.', 45, '"hi"', 0.25]

# defaults for urllib.parse.quote_plus, leaving these out would change nothing
kwargs = dict(safe='', encoding=None, errors=None) 

# by default, use slash separator and urlencoding
bind(*things_to_bind, **kwargs)
'castable/to/s+t+r+i+n+g./45/%22hi%22/0.25'

# turn off url encoding
bind(*things_to_bind, url=False, **kwargs)
'castable/to/s t r i n g./45/"hi"/0.25'

# result is the same if you pass in a list
bind(things_to_bind, url=False, **kwargs)
'castable/to/s t r i n g./45/"hi"/0.25'

# change separator --- note that it strips the other . in things_to_bind[2]
bind(*things_to_bind, sep='.')
'castable.to.s+t+r+i+n+g.45.%22hi%22.0.25'

# pointless but possible, and will strip W, H and Y from items in iterable!
bind(*things_to_bind, sep='WHY', url=True, **kwargs)
'castableWHYtoWHYs+t+r+i+n+g.WHY45WHY%22hi%22WHY0.25'

除了url=boolsep=str,所有关键字参数都传递给urllib.parse.quote_plus

测试(覆盖率300%)

coverage run -m unittest
coverage report --omit=tests/*
Name               Stmts   Miss  Cover
--------------------------------------
bind/__init__.py       2      0   100%
bind/bind.py          10      0   100%
--------------------------------------
TOTAL                 12      0   100%

项目详情


下载文件

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

源代码分发

bind-2.1.0.tar.gz (2.6 kB 查看哈希值)

上传时间: 源代码

支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页