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

python系列------输入输出

时间:2015-07-22 07:00:16      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:python   字符串   please   star   

输入

x = 3

print(x)

age=input(“please input string:”)

input函数的使用

技术分享

input函数是读取的字符串,不可以当做整形来使用

【示例】

star=input(‘input your age:’)

当你输入一个数字时比如是22,你再通过赋值是不可以的

age=age+1

技术分享

如上提示,表示age是string没有int的功能

由此可见,通过函数input()输入的内容是string

1.1    输出

print()函数,直接打印输出

技术分享

格式输出

在print()函数中再去调用format()函数

技术分享

如果想输出整形可以调用python的内置函数int()

age=int(age)

age=age+1

技术分享

本文出自 “技术博” 博客,谢绝转载!

python系列------输入输出

标签:python   字符串   please   star   

原文地址:http://hostman.blog.51cto.com/6303208/1676909

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