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

python交互式(input)

时间:2017-06-06 22:07:24      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:python交互式(input)

#交互式输出

#!/usr/bin/env   python
# -*- coding:utf-8 -*-
name = input("what is your name?")
password = input("Please enter password?")
print(name, password)

执行输出:
what is your name?xcn
Please enter password?admin@1234
xcn admin@1234

#交互式格式输出

#!/usr/bin/env   python
# -*- coding:utf-8 -*-
name = input("name:")
age = input("age:")
job = input("job:")
salary = input("salary:")
info = ‘‘‘
-----------info %s-------------
name : %s
age : %s
job : %s
salary : %s
‘‘‘ % (name, age, job, salary)
print(info)

执行输出:
name:xcn
age:20
job:12
salary:2000

-----------info xcn-------------
name : 20
age : 12
job : 2000
salary : 123

#注释:
% 相当于shell 中的$
s 相当于string 字符串

#定义打印(print)类型

#!/usr/bin/env   python
# -*- coding:utf-8 -*-
age = int(input("age:"))
print(type(age), type(str(age)))






本文出自 “小菜鸟” 博客,请务必保留此出处http://baishuchao.blog.51cto.com/12918589/1932890

python交互式(input)

标签:python交互式(input)

原文地址:http://baishuchao.blog.51cto.com/12918589/1932890

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