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

冷暖自知 提交于 2020-03-17 06:08:13

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!