Python使用什么划分语句块?
发布时间:2026-03-23 22:16:27

python以缩进格式划分句块。在代码前放置空间缩进句子以创建句子块。句子块中的每行必须有相同的缩进量。
缩进:Python开发者故意使违反缩进规则的程序无法编译,从而强迫程序员养成良好的编程习惯;
增加缩进表示句块的开始,减少缩进表示句块的退出。
示例:
thisisaline thisisaline thisisanotherblock continuingthesameblock thelastlineofthisblock phew,thereweescapedtheinnerblock
但在Python中,冒号(:)用来标记句块的开始,块中的每个句子都是缩进的(缩进量相同)。
请关注Python自学网了解更多Python知识。
下一篇 python中%d是什么
