码迷,mamicode.com
首页 > 编程语言 > 详细

python 学习笔记

时间:2017-08-05 22:50:44      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:hello   提示   undefined   显示   work   str   efi   name   lease   

1、当你输入name = raw_input()并按下回车后,Python交互式命令行就在等待你的输入了。这时,你可以输入任意字符,然后按回车后完成输入。

2、

但是程序运行的时候,没有任何提示信息告诉用户:“嘿,赶紧输入你的名字”,这样显得很不友好。幸好,raw_input可以让你显示一个字符串来提示用户,于是我们把代码改成:

name = raw_input(‘please enter your name: ‘)
print ‘hello,‘, name

再次运行这个程序,你会发现,程序一运行,会首先打印出please enter your name:,这样,用户就可以根据提示,输入名字后,得到hello, xxx的输出:

C:\Workspace> python hello.py
please enter your name: Michael
hello, Michael

python 学习笔记

标签:hello   提示   undefined   显示   work   str   efi   name   lease   

原文地址:http://www.cnblogs.com/idea678/p/7291596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!