Python Learning record-2016-12-20

Source: Internet
Author: User

String manipulation:

#!/usr/bin/env python# -*- coding: utf-8 -*-# author:jack niuname =   "My \tname is {name}" #加入一个tab键的空格print (Name.capitalize ()) Capital Letter print (Name.count ("a")) # How many aprint in the string (Name.center (50,  "-")) #长度50, in the middle, two times-padded print (Name.endswith ("Cke")) #是否以cke结尾print ( Name.expandtabs (tabsize=30)) #30的tabsiziprint (Name.find ("is") #查找is的第一个字母的indexprint (Name.format_map ( {" Name ": " Niubin "} )") #替换print ("1 A". Isalnum ()) #是否是阿拉伯数字 + Arabic character print ("Sssaa". Isalpha ()) #是否是英文字母print ("10" . Isdecimal ()) #是否十进制print ("Ten". IsDigit ()) #是否是数字print ("a10a". Isidentifier ()) #判断是不是一个合法的标识符, variable name print ("a10a". Islower ()) #是否是小写print ("3333". IsNumeric ()) #是否是数字print (" ". Isspace ()) #是否是空格print ("My name is  jack ". Istitle ()) #是否是titleprint (" My name is jack ". Isprintable ()) #是否能打印, some files cannot be printed print (" My  name is jack ". Isupper ()) #是否大写print (", ". Join ([" 1 ", " 2 ", " 3 " ]) # #1, 2, 3 Add comma print ("My name is jack") in the middle. Ljust (50,  "*")) #长度50, left * padded print ("My name is jack". Rjust (50,  "-")) #长度50, right-padded print ("my  Name is jack ". Lower ()) #把大写变成小写print (" My name is jack ". Upper ()) #把小写变成大写print (" my  Name is jack ". Replace (" My ", " my ",  1)) #把小写变成大写, replace print ("  alex ". Lstrip ()) # Remove the left space and enter print ("alex ". Rstrip ()) #去掉右边的空格和回车print (" Alex ". Strip ()) #去掉左边和右边的空格和回车p  =  Str.maketrans ("abcdef",  "123456") print ("Alex li". Translate (p)) #将alex  li Replace with the corresponding character in 123456 print ("1+ 2+3 ". Split (" + ")) #以加号切片print (" 1+2\n+3+4 ". Splitlines ()) #以换行符切片print (" Alexli ". Swapcase ()) #全部转换为大小写反向print (" My  name is jack ". RFind (" name ")) #print (" My name is jack ". Zfill ()) #在前边补0


Python Learning record-2016-12-20

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.