python学习笔记整理----输入、输出与数值类型

python输入与输出

python的输出

python2 : print “要打印的字符串”

python3 : print (“要打印的字符串”)

python的输入

python2 :
raw_input() : 接受字符串的数据;
input() : 只能接受数值类型;

# python2的操作
# name = raw_input("input name:")
# print name
#
# info = input("input:")
# print info

python3:
没有raw_input,只有input,
python3中为了避免记忆困难,用input接受数据,为字符串类型;

name = input("Name:")
print(name)
age = input("Age:")
print(age,type(age))

print "%s" %(001)
1
print "%d" %(001)
1
# 八进制转化为十进制
print "%d" %(0011)
9
# 十进制转化为八进制
print "%o" %(9)
11
print "%o" %(10)
12
print "%o" %(11)
13
# 十六进制转化为十进制
print "%x" %(16)
10
print "%x" %(17)
11
print "%x" %(11)
b
# 浮点数
print "%f" %(11)
11.000000
# 保留三位小数
print "%.3f" %(11)
11.000
print "%.2f" %(11)
11.00

# 要想输出%,要使用两个%。进行转义
print "内存占有率:%.2f%%" %(1.23324546456)
内存占有率:1.23%
python中支持的数据类型:int long float complex

python3中去掉了long

数据类型的转换:在python中,所有的数据类型。都可以作为内置函数,转换数据类型;
删除内存中的变量,可使用del

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值