Summary of Python built-in string methods, python strings
String processing is a very common skill, but there are too many built-in string methods in Python that are often forgotten. For quick reference, I wrote examples for each built-in method
Judgement-A bool value is usually returned.
Str. isalpha ()
Whether to include only text
Str. isdecimal ()
Whether to include only numbers (multilingual numbers)
Str. isdigit ()
Whether to include only numbers (0 ~
Basic articleThis chapter outlines:character encoding and interpreter codingVariable naming rules base data type (i) intunderlying data type (b) stringunderlying data type (iii) BOOLbasic data type (iv) ListUnderlying data type (v) tuplebasic data
This article mainly introduces some of the following Python's built-in string methods, including overview, string case conversion, string format output, string search positioning and substitution, string union and segmentation, string conditional
1. Arithmetic operation:2. Comparison operation:3. Assignment Operation:4. Logical Operation:5. Member Arithmetic: 1, intPython2 int has range, and long integer typePython3 all the numbers are int no matter how longOn a 32-bit machine, the number of
Python path [Article 2]: Python basics, python Article 2For Python, everything is an object, and objects are created based on classes.
Therefore, the following values are all objects: "zhurui", 22, ['beijing', 'shanghai', 'shenzhen'], and are
This article introduces the function example of the python3 string to describe the add function (append a string later)
S1 = 'hello' s2 = s1. _ add _ ('Boy! ') Print (s2) # output: Hello boy!
Contains (returns True if a string is included)
S1 =
1 #Author:ersa2 3Name ="Ersa"4 5 #Initial Capital capitalize ()6 Print(Name.capitalize ())7 8Name ="My name is Ersa"9 #number of substring repeats in stringTen Print(Name.count ("a")) One A #The Center () string prints the output in the middle and
Basic data types in detail one, str string1.capitalize string first letter capitalization Does not change itself, it generates a new value1 name = ' Zhangsan ' 2 new_name = name.capitalize () 3 print (name) 4 print (new_name) 5 6 output: 7 zhangsan8
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.