strip将输入信息前后空格去除
username = input("username:")
if username.strip() == 'liangml':
print('welcome')
split
name = "liangml,tom,jack"
name2 = name.split(",") #拆分以逗号分隔的字符串得到一个列表
print('|'.join(name2))#join是将name2结果以|形式合并到一起
print(name2)
capitalize 首字母大写
print(name.capitalize())
format字符串两种赋值方式
format字符串两种赋值方式msg = "Hello,{name},It's been a long {age} since last time sopke...."
msg2 = msg.format(name="zhangsan",age=111)
print(msg2)
msg2 = "lisi{0},dddd{1}"
print(msg2.format("liangml",22))
center 将字符串两边长度均匀分开
name = 'jack,tom,zhangsan,lisi'
print(name)
print(name.center(40,'-'))
find 查找赋值中有几个
print(name.find('a'))
isdigit 判断是否为数字
age = input('your age:')
if age.isdigit():
age = int(age)
else:
print('Invalid data type')
isalnum 判断不允许有特殊字符,返回布尔值
name = 'liangml'
print(name.isalnum())
endswith,startswith 分别判断字符串是不是以制定字符结尾或开始,返回布尔值
print(name.endswith("ml"))
print(name.startswith('ml'))
upper、lower 全部变大、全部变小
print(name.upper())
print(name.lower())
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。