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

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第三方库


热门话题
java从JPanel附加到窗口事件   java如何正确使用ArrayList?   java无法将@Serialize与requestfactory一起使用   java Photoshop脚本框架   java需要根据一些业务逻辑设置多个处理程序   java计算字符串正则表达式中的字母   安卓[JAVA][Parse Html]如何模拟按下按钮   java logback。xml:仅覆盖一个类的根级别   java无法解析符号“IOUtils”   java中图像的swing平滑缩放   spring无法转换“java”类型的值。lang.String“到所需类型”java。提交表单时lang.Long'错误   java字符串索引超出范围:1个循环错误   客户端服务器简单java聊天应用程序读取图像   java在线程启动之前获取线程ID   后台服务中无摄像机视图的java opencv图像处理   java Firebase实时数据库:如何停止脱机写入?(最佳方法)   java OpenSessionView和commit事务