How to truncate characters in python
Today, the editor will share with you the relevant knowledge points about how to truncate characters in python. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
1. Description
The lstrip () method is used to truncate the space to the left of the string or the specified character.
2. Syntax str.lstrip ([chars]) 3, parameter description
Str: the original string.
Chars: specifies the string to be truncated, which can be one character or multiple characters, matching not according to the entire string, but character by character in order.
4. Return value
Returns a new string generated after truncating the space to the left of the string or the specified character.
5. Instance str = "www. Manhuan. Net" str_val = str.lstrip () print (str_val)
Knowledge point expansion:
Truncate (delete) the specified character LSTRIP () on the left in PYTHON3
(str) .lstrip
Truncate (delete) the specified characters on the left, with spaces by default
Str5 = "AAAAAAA" str6 = "* AAAAAAAA" print (str5.lstrip ()) # (output) AAAAAAAprint (str6.lstrip ("*")) # (output) AAAAAAAA is all the content of this article "how to truncate characters in python". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.