习题14 提示和传递
来源:互联网 发布:淘宝店铺运营规划书 编辑:程序博客网 时间:2024/06/11 02:44
</pre><pre>
from sys import argvscript,user_name = argvprompt = '> 'print "Hi %s ,I'm the %s script."%(user_name,script)print "I'd like to ask you a few questions."print "Do you like me %s?"% user_namelikes = raw_input(prompt)print "Where do you live %s?"% user_namelives =raw_input(prompt)print "What kind of computer do you have?"computer = raw_input(prompt)print """Alright ,so you said %r about liking me.You live in %r. Not sure where that is.And you have a %r computer. Nice."""%(likes,lives,computer)
注意我们使用了
prompt = '> 'likes = raw_input(prompt)这样的语句,这样在需要输入的时候就会自带一个 > 符号了
结果是这样的
========================================================================
附加练习:
3.再添加一个参数
比如我们可以添加一个,绰号(chuohao)
from sys import argvscript,user_name,chuohao = argvprompt = '> 'print "Hi %s %s,I'm the %s script."%(user_name,chuohao,script)print "I'd like to ask you a few questions."print "Do you like me %s?"% user_namelikes = raw_input(prompt)print "Where do you live %s?"% user_namelives =raw_input(prompt)print "What kind of computer do you have?"computer = raw_input(prompt)print """Alright ,so you said %r about liking me.You live in %r. Not sure where that is.And you have a %r computer. Nice."""%(likes,lives,computer)
有如下结果
现在我成为了 David风行者(David WindRunner) 了!!
0 0
- 习题14 提示和传递
- 习题14--提示和传递
- 笨方法学Python 习题 14: 提示和传递
- 笨方法学习Python-习题14: 提示和传递
- 笨办法学Python习题14 提示和传递
- 练习14:提示和传递
- 笨办法14提示和传递
- Learn Python The Hard Way学习(14) - 提示和传递
- 第14个python程序:提示和传递
- 习题12 提示别人
- 给你的习题加上提示
- 《编程珠玑》—习题提示
- 习题12--raw_input()提示别人
- exercise14 提示 传递
- 0702学习笔记提示和传递和文件读取读写1
- 栈和队列 习题
- OC习题和答案
- 类和对象习题
- maven学习
- RuntimeWarning: Parent module 'settings' not found while handling absolute import
- HTML5开发Android程序
- forName()和loadClass()的区别
- Django入门:模板
- 习题14 提示和传递
- easyui tree树
- view加底线
- C语言实现双向循环链表
- Android中WebView与JS的交互
- mysql的简单使用
- 纠错: 深度学习模型优化时快速收敛
- HDU 4664 Triangulation-SG函数
- C#中ExecuteReader、ExecuteScalar、ExecuteNonQuery