Python 入門
下載Anconda
地址:https://www.anaconda.com/download/
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
直接一次點擊安裝
IDE jupyter notebook
在windowns下cmd里面打入 jupyter notebook
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
這就代表你的jupyter notebook啟動了
點擊new下面的python3便可以新建一個新的界面
<figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
認識一下常用的窗口
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
分別表示新建文件盹舞,打開文件乡小,復制,保存耐量,下載等
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
每一行代表一個cell,他的意思就是字面意思啦
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
然后還有一個比較常用的就是Kernel
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
當你進入死循環(huán)缩擂,就點擊interrupt或者restart
Python的基本數(shù)據(jù)類型 數(shù)字
python的基本數(shù)值類型包括 整形鼠冕,浮點數(shù),字符串胯盯,復數(shù)
通過type函數(shù)查看數(shù)據(jù)類型
<figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
類型的轉化
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
我們繼續(xù)掏出一個函數(shù):isinstance()
判斷數(shù)據(jù)類型是否為某一數(shù)據(jù)類型
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
Python的基本數(shù)據(jù)類型——字符串
字符串之所以區(qū)別于其他數(shù)據(jù)類型懈费,是因為它是被包含在引號里面的
你可以用單引號,也可以用雙引號
劃重點:但是不能一邊單引號博脑,一邊雙引號憎乙!
當然,有時候我們必須單引號和雙引號都得使用:趋厉,#代表注釋
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
轉義 \
Python用反斜杠(\)來轉義字符
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
常用字符串相關操作方法
len()取長度
-
字符串連接
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
字符串索引 與R不同寨闹,python是從0開始
字符串切片image<figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
有時,我可能想打印 \t
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>
<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;"><figcaption style="margin: 10px 0px 0px; padding: 0px; line-height: inherit; text-align: center; color: rgb(153, 153, 153); font-size: 0.7em;">mark</figcaption>
</figure>