Learn Python The Hard Way(11)

本文详细介绍了Python中如何实现基本的输入输出操作,并通过实例展示了如何收集用户信息并进行展示,适合初学者理解输入输出的基础用法。

So far you have only been printing, but you haven't been able to get any input from a person, or change it. You may not even know what "input" means, so rather than talk about it, let's have you do some and see if you get it. Next exercise we'll do more to explain it.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()
print "So, you're %r old, %r tall and %r heavy." % (age , height, weight)

代码运行结果如下:

                                  134958_OrhN_189901.jpg

Notice that we put a , (comma) at the end of each print line. This is so that print doesn't end the line with a newline and go to the next line


转载于:https://my.oschina.net/xtfjt1988/blog/401803

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值