Python入門(一)

Python 入門

下載Anconda

地址:https://www.anaconda.com/download/

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

直接一次點擊安裝

IDE jupyter notebook

在windowns下cmd里面打入 jupyter notebook

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

這就代表你的jupyter notebook啟動了
點擊new下面的python3便可以新建一個新的界面

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

認識一下常用的窗口

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

分別表示新建文件盹舞,打開文件乡小,復制,保存耐量,下載等

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

每一行代表一個cell,他的意思就是字面意思啦

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

然后還有一個比較常用的就是Kernel

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

當你進入死循環(huán)缩擂,就點擊interrupt或者restart

Python的基本數(shù)據(jù)類型 數(shù)字

python的基本數(shù)值類型包括 整形鼠冕,浮點數(shù),字符串胯盯,復數(shù)
通過type函數(shù)查看數(shù)據(jù)類型

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

類型的轉化

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

我們繼續(xù)掏出一個函數(shù):isinstance()

判斷數(shù)據(jù)類型是否為某一數(shù)據(jù)類型

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

Python的基本數(shù)據(jù)類型——字符串

字符串之所以區(qū)別于其他數(shù)據(jù)類型懈费,是因為它是被包含在引號里面的
你可以用單引號,也可以用雙引號
劃重點:但是不能一邊單引號博脑,一邊雙引號憎乙!

當然,有時候我們必須單引號和雙引號都得使用:趋厉,#代表注釋

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

轉義 \

Python用反斜杠(\)來轉義字符

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

常用字符串相關操作方法

len()取長度

  • 字符串連接
    字符串索引 與R不同寨闹,python是從0開始
    字符串切片

    <figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
    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;">
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>

<figure style="margin: 0px; padding: 0px; font-size: inherit; color: inherit; line-height: inherit;">
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>

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末君账,一起剝皮案震驚了整個濱河市繁堡,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌乡数,老刑警劉巖椭蹄,帶你破解...
    沈念sama閱讀 219,539評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異净赴,居然都是意外死亡绳矩,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,594評論 3 396
  • 文/潘曉璐 我一進店門玖翅,熙熙樓的掌柜王于貴愁眉苦臉地迎上來翼馆,“玉大人,你說我怎么就攤上這事金度∮γ模” “怎么了?”我有些...
    開封第一講書人閱讀 165,871評論 0 356
  • 文/不壞的土叔 我叫張陵猜极,是天一觀的道長中姜。 經(jīng)常有香客問我,道長跟伏,這世上最難降的妖魔是什么丢胚? 我笑而不...
    開封第一講書人閱讀 58,963評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮受扳,結果婚禮上携龟,老公的妹妹穿的比我還像新娘。我一直安慰自己勘高,他們只是感情好骨宠,可當我...
    茶點故事閱讀 67,984評論 6 393
  • 文/花漫 我一把揭開白布浮定。 她就那樣靜靜地躺著,像睡著了一般层亿。 火紅的嫁衣襯著肌膚如雪桦卒。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,763評論 1 307
  • 那天匿又,我揣著相機與錄音方灾,去河邊找鬼。 笑死碌更,一個胖子當著我的面吹牛裕偿,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播痛单,決...
    沈念sama閱讀 40,468評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼嘿棘,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了旭绒?” 一聲冷哼從身側響起鸟妙,我...
    開封第一講書人閱讀 39,357評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎挥吵,沒想到半個月后重父,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,850評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡忽匈,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,002評論 3 338
  • 正文 我和宋清朗相戀三年房午,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片丹允。...
    茶點故事閱讀 40,144評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡郭厌,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出雕蔽,到底是詐尸還是另有隱情折柠,我是刑警寧澤,帶...
    沈念sama閱讀 35,823評論 5 346
  • 正文 年R本政府宣布萎羔,位于F島的核電站,受9級特大地震影響碳默,放射性物質發(fā)生泄漏贾陷。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,483評論 3 331
  • 文/蒙蒙 一嘱根、第九天 我趴在偏房一處隱蔽的房頂上張望髓废。 院中可真熱鬧,春花似錦该抒、人聲如沸慌洪。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,026評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽冈爹。三九已至涌攻,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間频伤,已是汗流浹背恳谎。 一陣腳步聲響...
    開封第一講書人閱讀 33,150評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留憋肖,地道東北人因痛。 一個月前我還...
    沈念sama閱讀 48,415評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像岸更,于是被迫代替她去往敵國和親鸵膏。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,092評論 2 355

推薦閱讀更多精彩內(nèi)容