#-*-Coding:utf-8-*-
#Author: Gxli
#字符串的操作
Name= ' Zhangsan,lisi,wangwu '
#分割操作
Name=name.split (', ')
Print (name) #[' Zhangsan ', ' Lisi ', ' Wangwu ']
#列表转字符串拼接
Name= ' | '. Join (name)
Print (name) # ZHANGSAN|LISI|WANGWU
#去除开头结尾制定字符
Name2= ' LGX '
Name2=name2.strip () #name2 =name2.strip (")
Print (len (name2)) #3
#特殊显示
Print (Name2.center, '-') #------------------LGX-------------------
#查找字符并显示字符的下标
Print (Name2.find (' G ')) #1
#判断是否包含空格
Print ("in name2) #False
#首字母大写
Print (Name2.capitalize ()) #Lgx
#格式化显示
msg= "Hello, {name} it ' s been along {age}"
Msg2=msg.format (name= ' lll ', age=22)
Print (MSG2)
#isdigit () to determine whether a number
Age=input (' Your Age: ')
If Age.isdigit ():
Age=int (age)
Else
Print (' Invalid data type ')
#判断是否包含违法字符
name3= ' ALE3SDF '
Print (Name3.isalnum ())
#判断是否已dfsd结尾
Print (Name3.endswith (' DFSD '))
#判断是否已dfsd开头
Print (Name3.startswith (' DFSD '))
#大小写转换
Print (Name3.upper (). Lower ())
Python's operations on strings