基础语法字符串

#!/user/bin/env pythn
# -*- coding:utf-8 -*-

tem='Aiaoq {0}iang'
print(tem.capitalize())#首字母大写
print(tem.center(30)) #居中显示
print(tem.endswith("o"))#末尾字符
print(tem.expandtabs(10))#tab键转换成空格
print(tem.find('i'))#查询并返回位置
print(tem.format(2))#字符格式化
tem1='xi ao1'
print(tem1.isalnum())#检查是否字母加数字
print(tem1.isspace())#是否空
tem3=['Hong','huang']
print('_'.join(tem3))#连接
print(tem.ljust(2))#左对齐
print(tem.strip())#去除空格

s='ad c fg'
print(s.partition('c'))#分列
print(s.replace('a','A'))#替换
print(s.split('d'))#分割
#内存地址
n1=123
print(id(tem))
#小写变大写
print(tem.upper())

猜你喜欢

转载自www.cnblogs.com/nyqxiaoqiang/p/12133739.html