Python built-in data operations (1) --- string str, pythonstr
S. capitalize ()-> str Return a capitalized version of S, I. e. make the first character have upper case and the rest lower case.Returns an upper-case string that converts the first
What is a regular expression?Many programming languages support regular expressions. This article only discusses Regular Expressions in JavaScript.
Create a regular expressionMethod 1:
Var reg =/pattern/; Method 2:
Var reg = new RegExp ('pattern');
Introduction to Python str class methods
#capitalize (): string first character uppercase String = ' This is a string. ' New_str = String.capitalize () print (NEW_STR) #输出: The is a string. #center (width, fillchar=none): Place the string in the
Document directory
C {n}
C {m, n}
C {n ,}
*, + ,?
Greedy and non-greedy
Matching results of sub-regular expressions are not recorded
Forward pre-Query
?!
Global match, modifier g
Case-insensitive, modifier I
The end of the first line,
functions defined within the STR type
Capitalize: Capitalize the first letter, the remaining lowercaseFunction prototype: def capitalize (self)Usage:
Str1.capitalize ()
Casefold: Change All lowercaseFunction prototype: def
List&dict&stringThese three types are the most commonly used data types in Python. They're all a kind of sequence.Sequence common operations1. shardingS[A:B] Returns the fragment from S[a] to s[b-1] in the sequence s. Note s[0:0] is an empty set and
StrSlice Str[start:end] Note: Gu Tou regardless of tailSTR[M:N:S] s for stepCase Conversion Ret1 = S1.capitalize () Capitalize first letter ret = S1.lower () convert all to writeret = S1.upper () convert all to writeret = S1.swapcase ()?? Write to
First, let me declare that I spent more than two hours getting regular expressions before writing this article. Miserable ~ Miserable ~ Miserable ~According to the general idea, let's take a look at several other plug-in Methods: I use a stringCopy
I spent more than two hours working on regular expressions before writing this article. I will introduce the specific implementation ideas for you. If you are interested, refer to the following. First, let me declare it, I spent more than two hours
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.