Python是解析性語言,Python解釋器將源程序解釋並執行。
基本語法
print() --打印字符串
-直接打印
print("hello world")
結果:
hello world
-打印字符串變量
hello = 'hello world'
print(hello)
結果:
hello world
-打印unicode編碼
hello = 'hello\u0020world'
print(hello)
結果:
hello world
Python根據對齊縮進來區分程序塊
代碼一:
while count < 5:
print(count)
# count = 100
count = count + 1
print(123)
輸出結果爲:
0
1
2
3
4
5
123
代碼二:
count = 0
while count < 10:
print(count)
# count = 100
count = count + 1
print(123)
輸出結果爲:
0
123
1
123
2
123
3
123
4
123
5
123
代碼一與代碼二唯一的區別就是對齊不一樣,導致的結果就截然不同,所以在使用python編程時必須注意代碼縮進與對齊的問題。