- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 113字
- 2021-07-02 14:00:19
Indentation and tabs
Indentation is a must when writing block code in Python. Indentation is useful when you are writing functions, decision-making statements, looping statements, and classes. This makes it easy to read your Python programs.
We use indentation to indicate the block of code in Python programs. To indent a block of code, you can use spaces or tabs. Refer to the following example:
if val1 > val2:
print ("val1 is greater than val2")
print("This part is not indented")
In the preceding example, we indented the print statement because it comes under the if block. The next print statement doesn't come under the if block and that's why we didn't indent it.
推薦閱讀
- 微服務設計(第2版)
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- 人人都是網站分析師:從分析師的視角理解網站和解讀數據
- SQL Server實用教程(SQL Server 2008版)
- Orleans:構建高性能分布式Actor服務
- Hadoop 2.X HDFS源碼剖析
- Python語言科研繪圖與學術圖表繪制從入門到精通
- Node.js區塊鏈開發
- 零基礎輕松學C++:青少年趣味編程(全彩版)
- 現代C:概念剖析和編程實踐
- AI自動化測試:技術原理、平臺搭建與工程實踐
- Python預測分析實戰
- Java EE 7 Development with WildFly
- Jakarta EE Cookbook
- 高性能MVVM框架的設計與實現:San