Because the user reflects, in the basic article on the string function is too little to explain, so write an article in detail about the commonly used string functions. This article is about: Programmers take you 10 days to get started Python, play computer software development (iii) the elaboration and expansion of string functions.
If you want to learn and participate in this tutorial to improve and write. Please reply to the relevant questions in the discussion area below. Together to improve the writing of this article tutorial.
Python string common functions.
To declare a string variable:
str = ' focus on doing all-stack siege Lion, write code to read, love the whole stack, more love life. ’
All of the following string function functions are performed on the variable str:
To find the string length:
function use:
Operation Result:
It is worth noting that the length of a Chinese character is 3
Case-handling related functions:
Code:
Operation Result:
Uppercase and lowercase swaps and first-letter capitalization functions
Function:
Operation Result:
3. String Lookup function:
1. Search for the specified string, no return-1:
function display:
Operation Result:
4. String substitution function:
Function Demo:
Operation Result:
5. Remove the spaces on both sides of the string:
Function Demo:
Run results
6. Split string:
Function Description:
Operation Result:
The usual functions of the Python string are described here first. There are other related functions that must be updated later.
Learn the full stack technology please follow and add QQ Group: 538742639
Next: Python Development Practical Tutorials (8)-Submit data to Web pages
Python Learning starter Tutorial, String function extensions