Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to truncate characters in python

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report