学习了Python那么长的世界,有没有玩转过hello word?
2019獨角獸企業重金招聘Python工程師標準>>>
很多人學習Python很長時間,對于'hello word' 的認知,很多已經從事Python多年的程序員的認知也就只有:
print(hello wrod)但是有沒有讓hello word 變得不一樣?讓你裝一下逼?(想要源碼可以加群:725479218,群文件里面可以找到)
開始 (先決條件)
首先在你的操作系統上安裝 Anaconda (Python)。你可以從官方網站下載 anaconda 并自行安裝,或者你可以按照以下這些 anaconda 安裝教程進行安裝。
-
在 Windows 上安裝 Anaconda:
-
在 Mac 上安裝 Anaconda:
-
在 Ubuntu (Linux) 上安裝 Anaconda:
(不會的,或者想獲取安裝方法的可以加群:725479218)
打開一個 Jupyter Notebook
打開你的終端(Mac)或命令行,并輸入以下內容(請參考視頻中的 1:16 處)來打開 Jupyter Notebook:
jupyter notebook
打印語句/Hello World
在 Jupyter 的單元格中輸入以下內容并按下 shift + 回車來執行代碼。
# This is a one line comment print('Hello World!')效果如下圖
字符串和字符串操作
字符串是 Python 類的一種特殊類型。作為對象,在類中,你可以使用 .methodName() 來調用字符串對象的方法。字符串類在 Python 中默認是可用的,所以你不需要 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)查詢方法的功能
對于新程序員,他們經常問你如何知道每種方法的功能。Python 提供了兩種方法來實現。 1、(在不在 Jupyter Notebook 中都可用)使用 help 查詢每個方法的功能。
2.(Jupyter Notebook 專用)你也可以通過在方法之后添加問號來查找方法的功能。
# To look up what each method does in jupyter (doesnt work outside of jupyter)firstVariable.lower?結束語
如果你對本文或在 YouTube 視頻的評論部分有任何疑問,請告訴我們。 還有其他的教程,需要的可以加群:725479218,群內提供技術分享、技術交流,需要學習資料的可以找群主。
轉載于:https://my.oschina.net/u/3849319/blog/1823460
總結
以上是生活随笔為你收集整理的学习了Python那么长的世界,有没有玩转过hello word?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2017-2018-2 20165211
- 下一篇: websocket python爬虫_p