Python学习---py数据类型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的数据类型
作者:小a玖拾柒
-------------------------------------------
个性签名: 所有的事情到最後都是好的,如果不好,那說明事情還沒有到最後~
本文版权归作者【小a玖拾柒】,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利!