Python之交互函数raw_input的初级用法

  • A+
所属分类:Python  编程&脚本
摘要

简单演示下raw_input函数用法。从标准输入中读取内容。

[root@Legion101 ~]# python raw_input.py
Plz input your name? : lookback
How old are you? : 26
What about your job? : IT
Hello lookback , You're 26 years old.
You're still very young.
You're a loser!
[root@Legion101 ~]# vi raw_input.py
[root@Legion101 ~]# 
[root@Legion101 ~]# python raw_input.py
Plz input your name? : lookback
How old are you? : 26  
What about your job? : IT


Hello lookback , You're 26 years old.
You're still very young.
You're a loser!
[root@Legion101 ~]# cat raw_input.py
#!/usr/bin/env python
#-*- encoding: utf-8 -*-
#########################################################################
# File Name: raw_input.py
# Author: LookBack
# Email: admin#dwhd.org
# Version:
# Created Time: 2015年08月20日 星期四 23时41分18秒
#########################################################################

name = raw_input("Plz input your name? : ")
age = raw_input("How old are you? : ")
job = raw_input("What about your job? : ")

if name == "lookback" :
    print ""
    print ""
    print "Hello %s , You're %s years old." % (name,age)
else :
    print "Sorry, %s I don't know you! But you're %s years old." % (name,age)
    print "This Python print"

if age <= "27" :
    print "You're still very young."
else :
    print "You're old!"

if job == "IT" :
    print "You're a loser!"
else :
    print "You''re very goog!"
[root@Legion101 ~]# 

Python之交互函数raw_input的初级用法

lookback

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:2   其中:访客  2   博主  0

    • avatar Summer 1

      你这个连基本的赋值类型都没有定义啊……,数值后面万一有空格咋办。。差评

        • avatar lookback 4

          @Summer 哈哈哈。。。sorry。。。确实不严谨。。。您还是一如既往的对我这样要求。。。这点必须和你学习