Python学习---Python数据类型1206

1.1. 字符串格式化

字符格式化输出

占位符 %s  s = string

       %d  d = digit 整数

       %f   f = float 浮点数,约等于小数

#version: python3.2.5
#author: ‘FTL1012‘
#time: 2017/12/6 17:20

#name=hhh      这个是错误的,因为没有用单引号/双引号括起来,当做一个变量赋值给
name = input("please input the name:")
age = input("please input the age:")
tel = input("please input the tel:")
if age.isdigit():
    if tel.isdigit():
        age = int(age)      #age必须是数字
        tel = int(tel)      #tel必须是数字
    else:
        exit ("something wrong...")
msg = '''
---------info of %s ---------
name: %s
age : %d
tel : %d
---------end  of %s ---------
''' %(name, name, age, tel, name)
print(msg)

1.2. Python的数据类型

image

猜你喜欢

转载自www.cnblogs.com/ftl1012/p/9381790.html