作者是一位從事軟件開發(fā)三年的普通程序員,一直以來所使用的計(jì)算機(jī)邏輯語言是RPGLE萨西,腳本語言CLLE旭旭,數(shù)據(jù)庫DB2。小眾語言就業(yè)面窄源梭,面對最近越來越火的Python也希望自己能跟上時(shí)代的步伐稍味。
-- 之后的文章更新都是圍繞著Python從0開始學(xué)習(xí)到....一直堅(jiān)持下去
-- 本專題學(xué)習(xí)閱讀的材料有《廖雪峰官網(wǎng)Python教程》《笨辦法學(xué)Python3》
-- 歡迎在評(píng)論區(qū)討論留言
1. Python3安裝
Python3的安裝還是比較簡便的,打開官網(wǎng)https://www.python.org/脑溢,直接點(diǎn)擊下方Download Python3.7.3
赖欣,下載好以后 打開安裝包直接安裝即可,mac環(huán)境下會(huì)自動(dòng)配置環(huán)境變量社牲。
2. Python3的第一次嘗試
安裝完成之后Python3的環(huán)境就算搭建好了搏恤。接下來在Terminal中湃交,做一些簡單嘗試。
FANGQIdeMacBook-Pro:~ fangqi$ python3
Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World!")
Hello World!
>>> print(1)
1
>>> print(True)
True
第一個(gè)程序當(dāng)然是Hello world息罗。在python3中直接使用print()輸出就好才沧。
3. 如何使用編輯器進(jìn)行多行Python代碼的編寫
編輯器根據(jù)個(gè)人喜好選取一款適合自己的就好。
運(yùn)行結(jié)果如下:
FANGQIdeMacBook-Pro:PythonStudy fangqi$ python3 ex1.py
Hello World!
Hello Again!
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
在python中行首有#
代表注釋行孩革。
如果需要多行注釋在每行前加#
4. python中的數(shù)字和計(jì)算
Python中的基本數(shù)據(jù)類型有:
- 整數(shù)
- 浮點(diǎn)數(shù)
- 布爾值
- 字符串
- 空值
None
(不能理解為0) - 變量
- 常量
FANGQIdeMacBook-Pro:PythonStudy fangqi$ python3 ex2.py
I will not count my chickens:
Hens 30.0
Roosters 97
Noew I will count the eggs:
6.75
Is it true 3+2<5-7?
False
What is 3+2? 5
What is 5-7? -2
Oh, that's why it's False.
How about some more.
Is it greater> True
Is it greater or equal? True
Is it less or equal? False