In life and work, python has always been a good helper. Among the many functions of python, I think text processing is the most commonly used. The following is a summary of common usage. The environment is python 3.3
0. BasicsIn python, str objects
This section describes how to process fonts on the game interface. The experiment uses real-time display of the current time and ball position on the interface as an example. For details, see the code.
I. Code
[Python]#-*-Coding: UTF-8 -*- Import
1. Introductionawk is a command under Linux, and his output of other commands is very powerful for processing files.Compared to grep's lookup, the SED editor, awk is especially strong when it comes to analyzing data and generating reports.Big. In
Sed:1, stream editor, which processes one line at a time. When processing, the currently processed rows are stored in a temporary buffer called pattern space, followed by the SED command to process the contents of the buffer, and after processing is
Introductiongrep (Global search Regular expression (RE) and print out of the line, full search of regular expressions and print out rows) is a powerful text search tool that uses regular expressions to search for text . and print out the matching
1. Document CollationWork number and name are recorded in the employee fileEmployee.txt:Jason SmithJohn DoeSanjay GuptaAshok SharmaRecord work number and salary in bonus fileBonus.txt:100 $5,000200300 $3,000400 $1,250Requires merging two files and
Grep: Text Filtering tool, (GREP,EGREP,FGREP) Sed: Text Editing Tool, Awk: Text Report Generatorgrep: Function Text Search tool to step through the target file matching checks according to user-specified ' mode, print matching linesgrep
1. Cat:concatnateOptions:-n:number Display Line numbers-e:end displays the identifier at the end of each line (the identifier at the end of each line in Linux is $, and $+ returns in Windows)-v:visible visible display of nonprinting characters2.
^ Beginning of the line.$ end of line.. Any character other than the line break.* The preceding character repeats 0 to several times.. * Used to match all characters.[] Define a set of characters that match any one by one characters in the group
grepIf you want to use a regular expression, add the parameter Grep-e "[a-z]+" #使用正则表达式or egrep "[a-z]+"-a-b output matches a few lines before or after the line-C to display a few lines at the same time-e matches multiple styles, such as GREP-E "cat"
Job One: organize regular expression Blogs1, what is the regularA regular is a method of describing a character or string with a combination of special meanings (called regular expressions).Or, the regular is the rule used to describe a class of
Regular expressionsJob One: organize regular expression BlogsRegular expressionsA regular expression is the rule of a string of characters in a class word.GrepThe grep command is useful in situations where a pattern-based search is performed on the
Egrep is another mode of grep, with the-e option (enabling or shutting down one or more of the commands), enabling the extended Regular expression engine feature to use patterns that extend the regular expression character and the combination of
One: Basic tutorials(1) file I/O is very similar to C language;io is input/output in the computer, that is, input and output. Because the program and runtime data resides in memory and is executed by the CPU, an ultra-fast compute core, where the
This article mainly introduces several commonly used text view commands and text processing commands.First introduce the text view commandCat: Used to connect files and displayNote: When there is only one file, it is used to view the contents of the
SED: Data flow editor; Awk: Generator for report textSED basic usage: (stream editor) stream editorLine EditorFull Screen Editor: Vi/vimSED: Memory space (mode space)By default, the source file is not edited, only the data in the pattern space is
Cut action and usage:Cut [-option] file nameCut-remove sections from all line of filesCut a piece of content from each line of a file-D: Specify the field delimiter, the default delimiter is a space-F: Specify the fields to display-f1,3 showing 1
1 Cut: Split the file in some way and then outputOption:-B Select by byte-D Custom Delimiter-F and-D are used together to specify which area or field[Email protected] ~]# CAT/ETC/PASSWD | Cut-d:-F 1 #以: Prints the first field as a delimiter[email
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.