[Python]基础语法(一)print
2018-01-26 17:25
465 查看
1、print里面的反斜杠
2、如果希望得到跨越多行的字符串,则可用三重引号字符串
3、格式化字符串 format string
双重格式化:
%r和%s
%r是用来做调试(debug)比较好,因为它会显示变量的原始数据(raw data),而%s和其他的符号是用来向用户显示输出的。
4、带运算符的打印
2、如果希望得到跨越多行的字符串,则可用三重引号字符串
3、格式化字符串 format string
my_name = 'Zed A. Shaw' my_age = 35 my_height = 74 my_weight = 180 my_eyes = 'Blue' my_teeth = 'White' my_hair = 'Brown' print "Let's talk about %s." % my_name print "He's %d inches tall." % my_height print "He's %d pounds heavy." % my_weight print "Actually that's not too heavy." print "He's got %s eyes and %s hair." %(my_eyes,my_hair) print "His teeth are usually %s depending on the coffee." % my_teeth输出结果:
双重格式化:
x = "There are %d types of people." %10 print x print "I said: %r." %x
%r和%s
%r是用来做调试(debug)比较好,因为它会显示变量的原始数据(raw data),而%s和其他的符号是用来向用户显示输出的。
4、带运算符的打印
print "."*10 end1="Y" end2="J" print end1+end2
相关文章推荐
- python002 Python3 基础语法
- 1、Python语法基础
- Python基础篇-Python基础语法
- Python3基础 print 输出helloworld
- python 基础语法
- [Python基础]004.语法(3)
- Python 基础语法_Python脚本文件结构
- Python 基础语法
- python入门基础语法
- Python基础语法学习第一篇
- python语法基础-cPickle.dump使用
- Python基础语法(2)——字典、函数定义使用、控制流(if&for&while)
- python学习笔记--基础语法
- Python 学习(一)基础语法
- python入门(一):基础语法
- 12月20日一周二次【Python基础语法】
- Python基础语法
- Python 基础语法(三)
- 01Python基础语法
- Python语法基础(四)匿名函数、文件操作