Python string manipulation:

Source: Internet
Author: User

#字符串操作
Starting with 0, negative subscript usage
0 first element, 1 last element,
-len first element, len-1 last element
name= "Qwe, ERW, Qwe"
Print (Name.index ("E")) #索引 view the subscript of a character
  2
Print (Name[0:4]) #切片 Gu Tou regardless of the tail
  qwe
Print (Name[0::2]) #步长
  Qe,ew W
Print (Name.strip ()) #脱掉
 Qwe, ERW, Qwe
Print (Name.split (",")) #以, split
  [' qwe ', ' ERW ', ' qwe ']
print (len (name)) #统计字符串长度
   the
name1 = "PPP,OOO,III"
Print (name + name1)
  Qwe, ERW, Qwe PPP,OOO,III
name1 = name +name1
Print (name1) #拼接字符串
  Qwe, ERW, Qwe PPP,OOO,III






Python string manipulation:

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.