Python是否等效于PHP的strip_tags? [英] Python's equivalent to PHP's strip_tags?

查看:121
本文介绍了Python是否等效于PHP的strip_tags?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python是否等同于PHP的strip_tags?

Python's equivalent to PHP's strip_tags?

http://php.net/manual/en/function.strip- tags.php

推荐答案

Python标准库中没有这样的东西.这是因为Python是通用语言,而PHP最初是面向Web的.语言.

There is no such thing in the Python standard library. It's because Python is a general purpose language while PHP started as a Web oriented language.

不过,您有3种解决方案:

  • 您很着急:自己动手做. re.sub(r'<[^>]*?>', '', value)可能是一种快速而肮脏的解决方案.
  • 使用第三方库(推荐使用,因为要有更多的防弹功能):美丽的汤是一种真的很好,没有任何安装,只需复制lib目录并导入即可. 完整的土豆和漂亮的汤
  • 使用框架.大多数Web Python开发人员从不从头开始编写代码,他们使用诸如 django 之类的框架为您自动执行此操作. 使用django的完整tuto .
  • You are in a hurry: just make your own. re.sub(r'<[^>]*?>', '', value) can be a quick and dirty solution.
  • Use a third party library (recommended because more bullet proof) : beautiful soup is a really good one and there is nothing to install, just copy the lib dir and import. Full tuto with beautiful soup.
  • Use a framework. Most Web Python devs never code from scratch, they use a framework such as django that does automatically this stuff for you. Full tuto with django.

这篇关于Python是否等效于PHP的strip_tags?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆