python起步
1.選擇python的理由
學(xué)習(xí)成本
應(yīng)用范圍
2.python的安裝
下載python(https://www.python.org/)
環(huán)境變量
python ide 編輯器
notepad++
sublime text
pycharm
anaconda:(本課程學(xué)習(xí)ide)
下載,安裝,環(huán)境變量 (https://www.anaconda.com/distribution/)
下載時(shí),指定路徑下載報(bào)異常,默認(rèn)下載C盤(pán)沒(méi)有問(wèn)題
https://jingyan.baidu.com/article/425e69e615da75be14fc1645.html(安裝指南)
3.print 函數(shù)使用
print('')
print('','','') 默認(rèn)輸出后,每個(gè)value空格隔開(kāi)
print('','','',sep=',',end='') 指定每個(gè)value空格符號(hào),結(jié)尾句號(hào)結(jié)束
4.python 注釋與換行
#:單行
雙重''' or 雙重""":包含之間的內(nèi)容為多行注釋
print('內(nèi)容過(guò)多可使用 \+回車(chē)鍵 換行')
5.單引號(hào)、雙引號(hào)及轉(zhuǎn)義符
輸出內(nèi)容存在單引號(hào) 或 雙引號(hào) 或 \ ,使用雙重''' or 雙重""":包含之間的內(nèi)容為輸出內(nèi)容
print(''' I'am good boy ''')
print(r'\n')
單個(gè)\為轉(zhuǎn)意字符使用:\\-》\ \\n->\n \\\\n->\\n
6.python數(shù)學(xué)運(yùn)算與數(shù)學(xué)函數(shù)
加:+
減:-
乘:*
除:/
余數(shù):%
乘方:**
取整://
四舍五入:round(a),round(a,b); a:小數(shù),b:為保留小數(shù)
絕對(duì)值取整:abs[]
math 數(shù)學(xué)函數(shù),需要導(dǎo)入工程包
import math
math.ceil(5.0)-->5
math.ceil(5.6)-->6
math.ceil(5.2)-->6
math.ceil(-5.6)-->-5
****向上取整,小數(shù)后!=0,都+1,負(fù)數(shù)時(shí)取整
math.floor(6.0)-->6
math.floor(5.6)-->5
math.floor(5.2)-->5
math.floor(-5.4)-->-6
***向下取整,取整數(shù),負(fù)數(shù)時(shí)-1
math.trunc(5.0)-->5
math.trunc(5.6)-->6
math.trunc(5.2)-->6
***截取整數(shù)位
pow 冪運(yùn)算
math.pow(2,4)-->2的4次方
http://www.runoob.com/python/python-numbers.html
轉(zhuǎn)載于:https://www.cnblogs.com/luochangwei2019/p/10705616.html
總結(jié)
- 上一篇: 关于 IntelliJ IDEA
- 下一篇: MQTT 5.0 新特性(三)| 有效载