Python中的print用法
来源:互联网 发布:java switch case用法 编辑:程序博客网 时间:2024/05/17 23:29
Python是一种解释型、面向对象、动态数据类型的高级程序设计语言
python是这几年很火的编程语言 ,它有着丰富的库,使得很多程序员迅速转行
学过编程的都知道 “hello world”,每门编程语言的第一个演示程序会是它,print是打印,就像电脑里的文本通过打印机打出出来让我们看到一样,我们打印的时候,可以打印英文,汉字,甚至是图案,Python的print也可以做到这些
因为现在python的快速发展,有很多版本,主要分为2.x和3.x版本 版本不同 用法稍微有点区别 大家一定要注意 下面分别解释
常见的数据类型:
1..整型 int
python 2.x写法
print 1
python 3.x写法
print(1)
2.浮点型 float
python 2.x写法
print 1.5
python 3.x写法
print(1.5)
3.字符型 str
下面打印hello world
python 2.x 的print写法
print 'Hello World!'
python 3.x的print写法
print('Hello World!')
先说这么几种数据结构 其余的参考点击打开链接(转载)
下来说下变量 ,
a = 1
print a变量a就是1 我们打印变量a就相当于打印了变量1
b = 'hello'
print b
格式化输出
s = 'china'print 'hello %s' % (s)
# hello china
我们可以让他高亮输出(以一种显眼的方式显示)
print '\033[1;31;40m'
\033[显示方式;前景色;背景色m #参考资料(http://blog.sina.com.cn/s/blog_44c594a70101wqro.html)
他们输出的效果是一样的
python中一切皆为对象,它可以把对象打印出来
阅读全文
1 0
- Python中的print用法
- Python print函数用法
- Python Print函数用法
- Python的print用法
- Python Print函数用法
- Python-print函数用法
- Python print用法
- Python中的print语句
- python中的print
- Python print函数用法,print 格式化输出
- Python print函数用法,print 格式化输出
- Python print函数用法,print 格式化输出
- Python print函数用法,print 格式化输出
- Python print函数用法,print 格式化输出
- Python print函数用法,print 格式化输出
- Python print函数用法,print格式化输出
- Python print函数用法,print 格式化输出
- Python print函数用法,print 格式化输出
- python运行出现IDLE's subprocess didn't make connection. Either IDLE can't start or personal firewal的解决方案
- FPGA与DSP5509A通过MCBSP接口通信
- PAT 乙级-1025 链表反转
- D
- 5.1 父类和子类的类型转换总结
- Python中的print用法
- mapreduce工作流程图(带注解)
- Linux搭建tomcat+jdk+mysql环境
- renderer.material 方法过时
- 二叉树前序,中序,后序
- 启程篇
- 图像标注工具labelImg安装教程 Ubuntu16.04和win7
- 文章标题
- 堆排序在C#中的实现