未知

autolink_p的Python项目详细描述


回购协议从给定字符串中提取url/email子字符串并将其转换为 链接(或任何自定义格式)。 类型,也适用于简单的方式定制更换。

安装

使用pip

安装
pip install autolink_py

用法

  • 用HTML格式替换URL
fromautolink_py.coreimportAutoLinkertext='This website is google.com'al=AutoLinker()new_text=al.linkify(text,replaced_type='HTML')# new_text -> 'This website is <a href="http://google.com">google.com</a>'
  • 将URL替换为降价格式
fromautolink_py.coreimportAutoLinkertext='This website is google.com'al=AutoLinker()new_text=al.linkify(text,replaced_type='MARKDOWN')# new_text -> 'This website is [google.com](http://google.com)'
  • 用自定义格式替换URL
# example: 'google.com' -> '<google.com><http://google.com>'fromautolink_py.coreimportAutoLinkerclassNewAutoLinker(AutoLinker):defreplace_url(self,text,url):'''
        implement replace_url to customize the format you need.

        Params:
            text: url text that shown originally
            url: newly generated link including complete protocal based on text.
        '''returnu'<{0}><{1}>'.format(text,url)text='The website is google.com'nal=NewAutoLinker()new_text=nal.linkify(text)# new_text -> 'The website is <google.com><http://google.com>'

学分

核心算法由开源repo引用:autolink

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

推荐PyPI第三方库


热门话题
java使用(BluetoothGattCharacteristic)特性中的数据创建、写入和保存csv文件。getValue()   java如何使用groupBy创建一个值为BigDecimal字段平均值的映射?   日期时间Java将iso_即时格式的字符串转换为日期   java如何检索和显示Android firebase的配置文件?   scala AWSJAVASDK:解压缩大小必须小于262144000字节   要应用于列表的java JSTL if条件   java在3个点之间画一个正方形   Kotlin java抽象类IllegaAccessError   java原语双值相等取决于大小?   java有没有一种方法可以对数据集使用compareTo()方法,而不必遍历数据集的每个元素?   java为什么我发送的每个UDP消息都会改变端口源?   重新选择文件时swing Java JTree冻结   java不知道我的游戏是怎么回事   Motif L&F中自定义组合框渲染器中的Java Swing消失文本   java Trade Me API访问前的OAuth