古人云:書山有路勤為徑 學(xué)海無涯苦作舟 。
注:一般標(biāo)榜著 “ XX天學(xué)會(huì)XX”、“ XX 分鐘了解XX”的文章都不會(huì)是讓你增長(zhǎng)功力的文章,如本文。
隨著互聯(lián)網(wǎng)發(fā)展,全球在快速數(shù)字化,編程這件事也從數(shù)十年前只有科研人研在實(shí)驗(yàn)室才能做的事變得越來越讓人們所熟悉。但是作為平時(shí)甚少接觸編程的小伙伴,是不是也會(huì)對(duì)計(jì)算機(jī)世界擁有一點(diǎn)點(diǎn)好奇心呢(比如電影《黑客帝國(guó)》、《源代碼》)?
Q1: "怎么進(jìn)入編程世界?"
首先,你要學(xué)會(huì)一門編程語言!
而我要推薦的計(jì)算機(jī)語言,答案已在標(biāo)題中被出賣***hon!Python是一門十分容易上手,但是又被IT業(yè)界廣泛使用的編程語言(Scratch這種圖形化編程雖然簡(jiǎn)單,但基本只能用于教學(xué))。2016年5月份Python在全球最受歡迎編程語言中排第五。
Q2: “Python如何學(xué)?”
如果你是一位從未接觸過編程語言的新手,請(qǐng)移步 這里。 此書作者是一位程序員大叔,大叔說了:“學(xué)編程,首先,得會(huì)打字!!不會(huì)打字您就別學(xué)了哈”。大叔的在書提出的觀點(diǎn)個(gè)人覺得也是值得學(xué)習(xí)的,無論用于編程還是其他事情,如:
As you study this book, and continue with programming, remember that anything worth doing is difficult at first. Maybe you are the kind of person who is afraid of failure so you give up at the first sign of difficulty. Maybe you never learned self-discipline so you can't do anything that's "boring." Maybe you were told that you are "gifted" so you never attempt anything that might make you seem stupid or not a prodigy. Maybe you are competitive and unfairly compare yourself to someone like me who's been programming for more than 20 years.
Whatever your reason for wanting to quit, keep at it. Force yourself. If you run into a Study Drill you can't do, or a lesson you just do not understand, then skip it and come back to it later. Just keep going because with programming there's this very odd thing that happens. At first, you will not understand anything. It'll be weird, just like with learning any human language. You will struggle with words, and not know what symbols are what, and it'll all be very confusing. Then one day BANG your brain will snap and you will suddenly "get it." If you keep doing the exercises and keep trying to understand them, you will get it. You might not be a master coder, but you will at least understand how programming works.”
萬事開頭難,但自己選擇的路,即使跪著也要走完。也許你是那種一碰到困難就想到放棄的人;也許你從未掌握“自律”這件事導(dǎo)致你無法做任何“枯燥”的事情;也許你一直被認(rèn)為是“天才”,所以你不會(huì)傻到嘗試去做那些有可能讓你看起來是一個(gè)笨蛋或者至少不是“神童”的事情;也許你覺得和我這種已經(jīng)編程超過20年的人比較編程這件事是一件逗逼的事情。
無論是什么原因使你想要退出,不要管它!要管住自己(譯者注:論“自虐”能力的重要性。)! 如果某一個(gè)練習(xí)你不會(huì)做,或者有一課你聽不明白,那就跳過它,然后再回來重新學(xué)習(xí)(譯者注:子曰:溫故而知新)。編程這事說起來是件奇怪的事情,當(dāng)你沒有領(lǐng)悟真諦的時(shí)候你只需要堅(jiān)持。像學(xué)習(xí)任何一門自然語言一樣,剛開始時(shí)可能總會(huì)感覺怪怪的。那些奇怪的單詞,那些你不知道的符號(hào),也許會(huì)讓你感到十分困惑。但只要你堅(jiān)持不懈,堅(jiān)持做本書中的那些練習(xí)并且嘗試著去理解它們。會(huì)有一天,你的腦子會(huì)突然閃出“哇哈~!原來是這樣!” 的頓悟時(shí)刻。也許你不會(huì)成為一個(gè)高級(jí)碼農(nóng),但是至少你將會(huì)知道編程到底是什么鬼。
言歸正傳,本文面向?qū)ο鬄榫哂幸欢↑c(diǎn)編程經(jīng)驗(yàn)的小伙伴,旨在快速了解Python的基本語法和部分特性。
前言
1. 基本類型和運(yùn)算符
2. 變量和集合
列表
元組
字典
集合
Python數(shù)據(jù)集合類型總結(jié)
列表 定義方式 li = [1,2,3,4,“Hello World”] (列表可以包含任意基本類型)
元組 定義方式 tup = (1,2,3,4) (和列表類似,但元組不可更改)
字典 定義方式 dic = {“one”:2,“tow”:3,“three”:0}(字典,就是字典嘛。以 key:value方式存在)
集合 定義方式 set=set(1,2,3,4)or set = {1,2,3,4} (集合里的元素是唯一的,集合支持 & | ^ + -操作)
3. Python 邏輯運(yùn)算符
4. Functions
5. Python中的類
6. Python的模塊(庫(kù))
7. Python中的高級(jí)特性(生成器、裝飾器:wraps)
[1]learnxinyminutes,本文代碼大部分取于該網(wǎng)站,在此對(duì)該網(wǎng)站作者表示感謝!
-
編程
+關(guān)注
關(guān)注
88文章
3616瀏覽量
93763 -
python
+關(guān)注
關(guān)注
56文章
4797瀏覽量
84729 -
計(jì)算機(jī)語言
+關(guān)注
關(guān)注
1文章
15瀏覽量
9382
原文標(biāo)題:7個(gè)案例15分鐘讓你了解Python套路!
文章出處:【微信號(hào):magedu-Linux,微信公眾號(hào):馬哥Linux運(yùn)維】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論