下载、清理、提取和解析内容的简单工具

strutil的Python项目详细描述


https://travis-ci.org/dakrauth/strutil.svg?branch=master

结构

简单的帮助函数,用于交替使用字符串和正则表达式(主要是)。

要求

  • Python3.4+

模块内容

strutil.is_string(obj)

Check if ^{tt2}$ is a string

strutil.is_regex(obj)

Check if ^{tt2}$ is a regular expression
strutil.replace(text, old, new, count=None, strip=False)

new替换textold子集。

old类型可以是字符串或正则表达式。

如果strip,则删除所有前导/尾随空白。

如果count,则替换指定的出现次数,否则全部替换。

strutil.remove(text, what, count=None, strip=False)

Like ^{tt13}$, where ^{tt8}$ replacement is an empty string.

strutil.replace_each(text, items, count=None, strip=False)

Like ^{tt13}$, where each occurrence in ^{tt17}$ is a 2-tuple of ^{tt18}$ pair.

strutil.remove_each(text, items, count=None, strip=False)

Like ^{tt20}$, where each occurrence in ^{tt17}$ is ^{tt22}$ to remove.

strutil.contains(text, what)

Check if ^{tt22}$ occurs in ^{tt7}$

strutil.find_first(data, what)

Search for ^{tt22}$ in the iterable ^{tt28}$ and return the index of the first match. Return ^{tt29}$ if no match found.

strutil.splitter(text, token=None, expected=2, default='', strip=False)

Split ^{tt7}$ by ^{tt32}$ into at least ^{tt33}$ number of results.

When ^{tt32}$ is ^{tt29}$, the default for Python ^{tt36}$ is used, which will split on all whitespace.

^{tt32}$ may also be a regex.

If actual number of results is less than ^{tt33}$, pad with ^{tt39}$.

If ^{tt10}$, than do just that to each result.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
opencv Java RTSP从流数据包保存快照   java如何在websocket onopen事件中访问spring mvc属性值?   JAVAutil。scanner如何在scanner中使用分隔符。在Java中使用分隔符?   滚动滚动BuffereImage Java   记事本++的nppexec中的java\t间距   java Spring使用额外的字段让很多人冬眠   处理如何使用java中的JSON执行shell命令   java使用数据绑定库绑定需要其他组件的事件   java无法从YAML文件中删除特定的key:value   Java帮助:将字符串转换为ArrayList<Integer>   java在使用数组作为变量时没有得到完整的数组   调用Axis 2 Web服务时发生java端点引用错误   java禁用log4j 2异常(apache的异常)   在java11:javax上发送电子邮件给Log4j2 SMTP Appender。邮件或雅加达。邮政   java无论如何都有一个线程来捕获中断异常,而不仅仅是放置时间。单元秒。睡觉   java如何将Android导航架构片段动画化为在旧片段上滑动?   数字小数部分的操作问题   java如何反复提问,直到我作为一个角色得到正确的答案