标签:art ali 长度 索引 and pytho 其他 python abs
msg ='Helle John'
print(f'{msg[6]}')
print(f'{msg[3:7:4]}')
print(len(msg))
print(f"{'john' in msg}")
print(f"{msg.startswith('Helle')}")#endswith 末尾
print(f"{msg.strip('h')}")# 移除两端
msg_list = msg.split('e') #rsplit()右切割
print(f'{msg_list}')
for i in msg:
print(i)
print(f"{msg.lstrip('h')}") #右移rstrip
print(f"{msg.lower()}")
print(f'{msg.upper()}')
jion()
lis = [1,2,'19']
print(f"':'.join(lis): {':'.join(lis)}") # 报错,数字不可和字符串拼接
# str之join()
lis = ['nick', 'male', '19']
print(f"':'.join(lis): {':'.join(lis)}")
':'.join(lis): nick:male:19
replace()
name = 'nick shuai'
print(f"name.replace('shuai','handsome'): {name.replace('shuai','handsome')}")
name.replace('shuai','handsome'): nick handsome
lidigit()
salary = '111'
print(salary.isdigit()) # True
salary = '111.1'
print(salary.isdigit()) # False
True
False
标签:art ali 长度 索引 and pytho 其他 python abs
原文地址:https://www.cnblogs.com/1naonao/p/10912691.html