学习了Python那么长的世界,有没有玩转过hello word?
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
很多人學(xué)習(xí)Python很長時(shí)間,對于'hello word' 的認(rèn)知,很多已經(jīng)從事Python多年的程序員的認(rèn)知也就只有:
print(hello wrod)但是有沒有讓hello word 變得不一樣?讓你裝一下逼?(想要源碼可以加群:725479218,群文件里面可以找到)
開始 (先決條件)
首先在你的操作系統(tǒng)上安裝 Anaconda (Python)。你可以從官方網(wǎng)站下載 anaconda 并自行安裝,或者你可以按照以下這些 anaconda 安裝教程進(jìn)行安裝。
-
在 Windows 上安裝 Anaconda:
-
在 Mac 上安裝 Anaconda:
-
在 Ubuntu (Linux) 上安裝 Anaconda:
(不會的,或者想獲取安裝方法的可以加群:725479218)
打開一個 Jupyter Notebook
打開你的終端(Mac)或命令行,并輸入以下內(nèi)容(請參考視頻中的 1:16 處)來打開 Jupyter Notebook:
jupyter notebook
打印語句/Hello World
在 Jupyter 的單元格中輸入以下內(nèi)容并按下 shift + 回車來執(zhí)行代碼。
# This is a one line comment print('Hello World!')效果如下圖
字符串和字符串操作
字符串是 Python 類的一種特殊類型。作為對象,在類中,你可以使用 .methodName() 來調(diào)用字符串對象的方法。字符串類在 Python 中默認(rèn)是可用的,所以你不需要 import 語句來使用字符串對象接口。
# Create a variable # Variables are used to store information to be referenced # and manipulated in a computer program. firstVariable = 'Hello World' print(firstVariable) # Explore what various string methods print(firstVariable.lower()) print(firstVariable.upper()) print(firstVariable.title()) # Use the split method to convert your string into a list print(firstVariable.split(' ')) # You can add strings together. a = "Fizz" + "Buzz" print(a)查詢方法的功能
對于新程序員,他們經(jīng)常問你如何知道每種方法的功能。Python 提供了兩種方法來實(shí)現(xiàn)。 1、(在不在 Jupyter Notebook 中都可用)使用 help 查詢每個方法的功能。
2.(Jupyter Notebook 專用)你也可以通過在方法之后添加問號來查找方法的功能。
# To look up what each method does in jupyter (doesnt work outside of jupyter)firstVariable.lower?結(jié)束語
如果你對本文或在 YouTube 視頻的評論部分有任何疑問,請告訴我們。 還有其他的教程,需要的可以加群:725479218,群內(nèi)提供技術(shù)分享、技術(shù)交流,需要學(xué)習(xí)資料的可以找群主。
轉(zhuǎn)載于:https://my.oschina.net/u/3849319/blog/1823460
總結(jié)
以上是生活随笔為你收集整理的学习了Python那么长的世界,有没有玩转过hello word?的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2017-2018-2 20165211
- 下一篇: 涂抹mysql笔记-mysql复制特性