day10-Python 基本数据类型介绍

数字:int  

#字符串转换整型
a = "123"
print(type(a),a)
b = int(a)
print(type(b),b)
b = b + 1000
print(b)

字符串:str

首字母大写:capitalize()

test = "charon"
v =test.capitalize()
print(v)

所有变小写lower()

test = "chAron"
v1 = test.lower()
print(v1)

设置宽度,并将内容居中

20代表总长度

*代表空白位置填充,一个字符可有可无

test = "charon"
v2 = test.center(20,"*")
print(v2)

  

扫描二维码关注公众号,回复: 5114170 查看本文章

布尔值:bool

列表:list

元祖: tuple

字典:dict

猜你喜欢

转载自www.cnblogs.com/charon2/p/10333143.html