Python 和文本操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/676253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 20:36:33  来源:igfitidea点击:

Python and text manipulation

pythontext

提问by ardsrk

I want to learn a text manipulation language and I have zeroed in on Python. Apart from text manipulation Python is also used for numerical applications, machine learning, AI, etc.

我想学习一种文本操作语言,并且我已经专注于 Python。除了文本操作之外,Python 还用于数值应用、机器学习、人工智能等。

My question is how do I approach the learning of Python language so that I am quickly able to write sophisticated text manipulation utilities. Apart from regular expressions in the context of "text manipulation" what language features are more important than others what modules are useful and so on.

我的问题是如何学习 Python 语言,以便我能够快速编写复杂的文本操作实用程序。除了“文本操作”上下文中的正则表达式之外,哪些语言功能比其他语言功能更重要,哪些模块有用等等。

回答by Van Gale

Beyond regular expressions here are some important features:

除了正则表达式,这里还有一些重要的特性:

For tools, I recommend looking at the following:

对于工具,我建议查看以下内容:

Edit:A good links specific to text processing in Python:

编辑:一个特定于 Python 文本处理的好链接:

回答by Eugene Morozov

There's a book Text Processing in Python. I didn't read it myself yet but I've read other articles of this author and generally they're a good staff.

有一本书Text Processing in Python。我自己还没有读过,但我读过这位作者的其他文章,总的来说他们是一个很好的员工。

回答by RedBlueThing

I found the object.__doc__ and dir(obj) commands incredibly useful in learning the language.

我发现 object.__doc__ 和 dir(obj) 命令在学习语言方面非常有用。

e.g.

例如

a = "test,test,test"

What can I do with a? dir(a). Seems I can split a.

我可以用 a 做什么?目录(a)。看来我可以拆分一个。

vec = a.split (",")

What is vec? vec.__doc__:

什么是vec?vec.__doc__:

"new list initialized from sequence's items"

“从序列的项目初始化的新列表”

What can I do with vec? dir(vec).

我可以用 vec 做什么?目录(vec)。

vec.sort ()

etc ...

等等 ...

回答by claws