String method
#字符串这些方法都不会改变原来字符串的值
name = ' Besttest '
# new_name = Name.strip () #默认是去掉空格和换行符
# new_name = Name.lstrip () #默认是去掉左边的空格和换行符
# new_name = Name.rstrip () #默认是去掉右边的空格和换行符
# new_name = Name.count (' t ') #查找某个字符在字符串里面出现的次数
# index = name.find (' t ') #找到这个字符串, returns its subscript, if not present, returns-1
# index = name.index (' d ') #找到这个字符串, returns its subscript, if not present, error
# Print (Name.upper ()) #把所有字母都变成大写的
# Print (Name.lower ()) #把所有字母都变成小写的
# file_name = ' A.xls '
# Print (File_name.endswith ('. xls ')) #判断一个字符串是否以xx结尾
# sql = ' Select,update,insert,drop,create,alter '
sql = ' select * from User;select '
sql.startswith (' select ') #判断一个字符串是否以xx开头
# f = ' {name} Welcome to age: {age} '
# # print (F.format (name= ' cyan ')) #字符串格式化
# d = {' name ': ' Flynn ', ' Age ':
# Print (F.format_map (d)) #字符串格式化, it goes in a dictionary.
new_sql = sql.replace (' Select ', ' Update ')
# Print (new_sql)
# Print (' 123 '. IsDigit ()) #是否是数字
# Print (' & '. Isalnum ()) #是否包含数字或字母
# st = ' a,b,c,d,f,g '
# st_list = St.split (', ') #字符串分割, returns a list, if nothing is written, is separated by a space
# Print (st_list)
slit = [' A ', ' B ', ' C ', ' d ', ' f ', ' G ']
s2 = ' hhhhhhh '
tu = (' H1 ', ' H2 ', ' H3 ', ' H5 ')
d ={' name ': ' N ', ' age ':
res = ' * '. Join (d) #数组连起来, return string
Print (res)
#可遗忘的
# new_name = Name.capitalize () Capitalize first letter
# Print (Name.center (50, ' * ')) put the string in the middle, with * on both sides
# print (' AaAA '. Islower ()) #是否全是小写字母
# print (' AA '. Isupper ()) #是否全是大写字母
# print (' Sdsad '. Isalpha ()) #是否包含英文字母
Day3-python Study Notes (iv)