Print函数
跨平台,但版本之间不太兼容,3.7 需要加括号,print()

- print()函数由两部分构成:1. 指令:print;2. 指令的执行对象:在print后面的括号里的内容。
- ()必须是英文环境下的,不要切换时搞错了
- 打印的意思是:让计算机把你给它的指令结果,显示在屏幕的终端上。
-
print()函数中引号的用法:当括号内有引号的时候,就相当于告诉计算机——你不需要执行多余的操作,我输入什么,你就打印什么。
print函数阐述总结
- 最常见的符号报错提示就是【syntaxError:invalid syntax】(语法错误:无效语法)
- 在print内部使用三引号'''(连续输入三个单引号)来实现自动换行。
- print打印多个变量用逗号","连接;注意用加号+时类型需要一致,","表示空格,“+”没有空格
转义字符

变量与赋值
-
变量需要被赋值,并且只能储存最新的赋值
变量命名规范
Python算术运算符
print相关知识总结
数据类型

世界级C++大佬Herb Sutter说的:“世上的人可以分为3类:一种是知道自己不懂浮点运算的;一种是以为自己懂浮点运算的;最后一种是极少的专家级人物,他们想知道自己是否有可能,最终完全理解浮点运算。”

判断函数
- Python代码的缩进规则。具有相同缩进的代码被视为代码块,如果 if 语句- 判断为 True,就会执行这个代码块。
- 缩进严格按照Python的习惯写法:4个空格,不要使用Tab,更不要混合- Tab和空格,否则很容易造成因为缩进引起的语法错误。
- 注意: if 语句后接表达式,然后用冒号:表示代码块开始。
- 如果在Python交互环境下敲代码,还要特别留意缩进,并且退出缩进需要多敲一行回车
- Python的 for 循环就可以依次把list或tuple的每个元素迭代出来,和 for 循环不同的另一种循环是 while 循环,while 循环不会迭代 list 或 tuple 的元素,而是根据表达式判断循环是否结束。用 for 循环或者 while 循环时,如果要在循环体内直接退出循环,可以使用break 语句.在循环过程中,可以用break退出当前循环,还可以用continue跳过后续循环代码,继续下一次循环。在python内部中还可以使用for循环的嵌套




input 函数:有问有答,需要在终端输入信息,为了输出需要赋值,输入值将会被强制转换成字符串。如果输入的是整数,需要在前面加int强制转换input的结果。




网友评论