1、首先我们输入print('hello'),输出了hello;接着我们输入print("hello world!")输出了hello world!,在python里,‘’和“”效果一样。需要输入单引号时用双引号包括单引号print("100+200=","'",100+200) 100+200= ' 300
2、print函数可以一次输出多个内容,各个参数之间用英文状态的,隔开。print("hello",&qu泠贾高框ot;world!")SyntaxError: invalid character in identifier>>> print("hello","world!")hello world!第一次显示语法错误,有非法字符就是应为输入了中文状态的逗号。
3、python不仅是可以输出字符,还可以输出变量和常亮的结果。>>> print(100+200)300 python自动算出了100+200>>> print("100+200="100+200)SyntaxError: invalid syntax 语法错误,两个参数之间应该有逗号。
4、如果我们想换行输入那怎么办呢?和别的变成语言一样,用转义符。>>> print(媪青怍牙"100+200=",\n,100+200)SyntaxError: unexpected character after line continuation character>>> print("100+200=",'\n',100+200)100+200=300换行的转义符是\t,且转义符也要用‘’包括起来。
5、tab的转义符是什么呢?>>> print("100+200=",'\tab',100+200)100+200= ab 300>>> print("100+200=",'\t',100+200)100+200= 300
6、如果我想输出\,那就这样。>>> print("100+200=",'\\',100+200)100+200= \ 300