- 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.
推薦閱讀
- 程序員考試案例梳理、真題透解與強(qiáng)化訓(xùn)練
- Windows Presentation Foundation Development Cookbook
- Python機(jī)器學(xué)習(xí)算法: 原理、實(shí)現(xiàn)與案例
- Instant PHP Web Scraping
- 并行編程方法與優(yōu)化實(shí)踐
- ActionScript 3.0從入門到精通(視頻實(shí)戰(zhàn)版)
- 零基礎(chǔ)學(xué)HTML+CSS第2版
- Android 游戲開(kāi)發(fā)大全(第二版)
- Python Automation Cookbook
- Java核心技術(shù)速學(xué)版(第3版)
- C語(yǔ)言從入門到精通(微視頻精編版)
- IBM Cognos Insight
- 修改代碼的藝術(shù)
- Java Web開(kāi)發(fā)從0到1
- 新標(biāo)準(zhǔn)C++程序設(shè)計(jì)