python1 raw_input与用户交互
raw_input与用户交互
基本输入姓名:
#!/usr/bin/env python name = raw_input("what is your name?") print "hello",name
raw_input 默认格式为字符串
将字符串转换为数字类型
age = init(raw_input("how old are you?"))
计算出生日期
#!/usr/bin/env python this_year = 2014 name = raw_input("what is your name?") name = init(raw_input("how old are you?")) print "Hello",name,"\n" print "you are",age,"years old!" print "so your are born in",this_year - age
本文出自 “八英里” 博客,请务必保留此出处http://5921271.blog.51cto.com/5911271/1408468
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。