跟著可叔學(xué)Python第三講 —— Installing PyCharm
(聽從好友的建議,從這集往后,標(biāo)題名將改為:Python零基礎(chǔ)視頻教程)
視頻內(nèi)容包括:
如何下載安裝PyCharm
如何創(chuàng)建你的第一個Project
什么是虛擬環(huán)境(virtual environment)?
為什么要創(chuàng)建虛擬環(huán)境(virtual environment)?
如何運(yùn)行你的代碼?
如何添加第三方類庫?
沒在視頻中交待的小技巧:
?如何查看當(dāng)前項(xiàng)目第三方類庫的安裝路徑
>>> import site>>> site.getsitepackages()['D:\\PycharmProjects\\Demo\\venv', 'D:\\PycharmProjects\\Demo\\venv\\lib\\site-packages']
另上集視頻中對于字符串的處理,在Python3.6中新增了f-string的寫法,比str.format()的寫法更為簡潔明了,而且運(yùn)行速度還快。建議采用最新的寫法,原有視頻并沒有介紹,在此補(bǔ)入:
先貼一下之前的str.format()的寫法:
>>> name = 'Fred'
>>> age = 42
>>> 'He said his name is {} and he is {} years old.'.format(name,age)He said his name is Fred and he is 42 years old.
如果用f-string來改寫,是這樣的:
>>> name = 'Fred'
>>> age = 42
>>> f'He said his name is {name} and he is {age} years old.'He said his name is Fred and he is 42 years old.
是不是簡潔了很多,只需要在字符串前面加上字母f,然后在{}里填入相應(yīng)的變量名就可以了。
不僅如此,f-string中的f是從fast而來,意味這這種寫法python解釋執(zhí)行起來的速度是很快的,這里貼一張圖,大家感受一下,可以看到,用f-strings的寫法的運(yùn)行時間是最少的。

本公眾號堅(jiān)持原創(chuàng),堅(jiān)持簡單粗鄙的排版(把更多的精力放花在視頻內(nèi)容的制作上),歡迎轉(zhuǎn)載,并請注明出處,請勿作任何商業(yè)用途。
謝謝大家的持續(xù)關(guān)注。