栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python学习(四)基本输入输出

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python学习(四)基本输入输出

 

     用Python进行程序设计 输入是通过input( )函数来实现的 input( )的一般格式为

x input( 提示 )

    该函数返回输入的对象。可输入数字、字符串和其它任意类 型对象。

   在Python 3.x中 input()函数用来接收用户的键盘输入 不论用户输入数据时使用什么界定符 input()函数的返 回结果都是字符串 需要将其转换为相应的类型再处理。

 x input( Please input: )
Please input:3
 print(type(x))
 class str 
 x input( Please input: )
Please input: 1 
 print(type(x))
 class str 
 x input( Please input: )
Please input:[1,2,3]
 print(type(x))
 class str 

   Python 3.x中使用print()函数进行输出。

 print(3, 5, 7)
3 5 7
 print(3, 5, 7, sep , ) #指定分隔符
3,5,7
 print(3, 5, 7, sep : )
3:5:7
 for i in range(10,20):
print(i, end ) #不换行
10 11 12 13 14 15 16 17 18 19

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/267770.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号