數(shù)學(xué)相關(guān)

創(chuàng)新互聯(lián)專(zhuān)注為客戶(hù)提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、懷遠(yuǎn)網(wǎng)絡(luò)推廣、小程序制作、懷遠(yuǎn)網(wǎng)絡(luò)營(yíng)銷(xiāo)、懷遠(yuǎn)企業(yè)策劃、懷遠(yuǎn)品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供懷遠(yuǎn)建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:chinadenli.net
abs(a) : 求取絕對(duì)值。abs(-1)
max(list) : 求取list最大值。max([1,2,3])
min(list) : 求取list最小值。min([1,2,3])
sum(list) : 求取list元素的和。 sum([1,2,3]) 6
sorted(list) : 排序,返回排序后的list。
len(list) : list長(zhǎng)度,len([1,2,3])
divmod(a,b): 獲取商和余數(shù)。 divmod(5,2) (2,1)
pow(a,b) : 獲取乘方數(shù)。pow(2,3) 8
round(a,b) : 獲取指定位數(shù)的小數(shù)。a代表浮點(diǎn)數(shù),b代表要保留的位數(shù)。round(3.1415926,2) 3.14
range(a[,b]) : 生成一個(gè)a到b的數(shù)組,左閉右開(kāi)。range(1,10) [1,2,3,4,5,6,7,8,9]
類(lèi)型轉(zhuǎn)換
int(str) : 轉(zhuǎn)換為int型。int('1') 1
float(int/str) : 將int型或字符型轉(zhuǎn)換為浮點(diǎn)型。float('1') 1.0
str(int) : 轉(zhuǎn)換為字符型。str(1) '1'
bool(int) : 轉(zhuǎn)換為布爾類(lèi)型。 str(0) False str(None) False
bytes(str,code) : 接收一個(gè)字符串,與所要編碼的格式,返回一個(gè)字節(jié)流類(lèi)型。bytes('abc', 'utf-8') b'abc' bytes(u'爬蟲(chóng)', 'utf-8') b'xe7x88xacxe8x99xab'
list(iterable) : 轉(zhuǎn)換為list。 list((1,2,3)) [1,2,3]
iter(iterable): 返回一個(gè)可迭代的對(duì)象。 iter([1,2,3]) list_iterator object at 0x0000000003813B00
dict(iterable) : 轉(zhuǎn)換為dict。 dict([('a', 1), ('b', 2), ('c', 3)]) {'a':1, 'b':2, 'c':3}
enumerate(iterable) : 返回一個(gè)枚舉對(duì)象。
tuple(iterable) : 轉(zhuǎn)換為tuple。 tuple([1,2,3]) (1,2,3)
set(iterable) : 轉(zhuǎn)換為set。 set([1,4,2,4,3,5]) {1,2,3,4,5} set({1:'a',2:'b',3:'c'}) {1,2,3}
hex(int) : 轉(zhuǎn)換為16進(jìn)制。hex(1024) '0x400'
oct(int) : 轉(zhuǎn)換為8進(jìn)制。 oct(1024) '0o2000'
bin(int) : 轉(zhuǎn)換為2進(jìn)制。 bin(1024) '0b10000000000'
chr(int) : 轉(zhuǎn)換數(shù)字為相應(yīng)ASCI碼字符。 chr(65) 'A'
ord(str) : 轉(zhuǎn)換ASCI字符為相應(yīng)的數(shù)字。 ord('A') 65
相關(guān)操作
eval****() : 執(zhí)行一個(gè)表達(dá)式,或字符串作為運(yùn)算。 eval('1+1') 2
exec() : 執(zhí)行python語(yǔ)句。 exec('print("Python")') Python
filter(func, iterable) : 通過(guò)判斷函數(shù)fun,篩選符合條件的元素。 filter(lambda x: x3, [1,2,3,4,5,6]) filter object at 0x0000000003813828
map(func, *iterable) : 將func用于每個(gè)iterable對(duì)象。 map(lambda a,b: a+b, [1,2,3,4], [5,6,7]) [6,8,10]
zip(*iterable) : 將iterable分組合并。返回一個(gè)zip對(duì)象。 list(zip([1,2,3],[4,5,6])) [(1, 4), (2, 5), (3, 6)]
type():返回一個(gè)對(duì)象的類(lèi)型。
id(): 返回一個(gè)對(duì)象的唯一標(biāo)識(shí)值。
hash(object):返回一個(gè)對(duì)象的hash值,具有相同值的object具有相同的hash值。 hash('python') 7070808359261009780
help():調(diào)用系統(tǒng)內(nèi)置的幫助系統(tǒng)。
isinstance():判斷一個(gè)對(duì)象是否為該類(lèi)的一個(gè)實(shí)例。
issubclass():判斷一個(gè)類(lèi)是否為另一個(gè)類(lèi)的子類(lèi)。
globals() : 返回當(dāng)前全局變量的字典。
next(iterator[, default]) : 接收一個(gè)迭代器,返回迭代器中的數(shù)值,如果設(shè)置了default,則當(dāng)?shù)髦械脑乇闅v后,輸出default內(nèi)容。
reversed(sequence) : 生成一個(gè)反轉(zhuǎn)序列的迭代器。 reversed('abc') ['c','b','a']
運(yùn)算
a = 21
b = 10
c = 0
c = a + b
print "1 - c 的值為:", c
c = a - b
print "2 - c 的值為:", c
c = a * b
print "3 - c 的值為:", c
c = a / b
print "4 - c 的值為:", c
c = a % b
print "5 - c 的值為:", c
a = 2
b = 3
c = a**b
print "6 - c 的值為:", c
a = 10
b = 5
c = a//b
print "7 - c 的值為:", c
python比較
a = 21
b = 10
c = 0
if ( a == b ):
print "1 - a 等于 b"
else:
print "1 - a 不等于 b"
if ( a != b ):
print "2 - a 不等于 b"
else:
print "2 - a 等于 b"
if ( a b ):
print "3 - a 不等于 b"
else:
print "3 - a 等于 b"
if ( a b ):
print "4 - a 小于 b"
else:
print "4 - a 大于等于 b"
if ( a b ):
print "5 - a 大于 b"
else:
print "5 - a 小于等于 b"
a = 5
b = 20
if ( a = b ):
print "6 - a 小于等于 b"
else:
print "6 - a 大于 b"
if ( b = a ):
print "7 - b 大于等于 a"
else:
print "7 - b 小于 a"
賦值
a = 21
b = 10
c = 0
c = a + b
print "1 - c 的值為:", c
c += a
print "2 - c 的值為:", c
c *= a
print "3 - c 的值為:", c
c /= a
print "4 - c 的值為:", c
c = 2
c %= a
print "5 - c 的值為:", c
c **= a
print "6 - c 的值為:", c
c //= a
print "7 - c 的值為:", c
邏輯運(yùn)算符:
a = 10
b = 20
if ( a and b ):
print "1 - 變量 a 和 b 都為 true"
else:
print "1 - 變量 a 和 b 有一個(gè)不為 true"
if ( a or b ):
print "2 - 變量 a 和 b 都為 true,或其中一個(gè)變量為 true"
else:
print "2 - 變量 a 和 b 都不為 true"
a = 0
if ( a and b ):
print "3 - 變量 a 和 b 都為 true"
else:
print "3 - 變量 a 和 b 有一個(gè)不為 true"
if ( a or b ):
print "4 - 變量 a 和 b 都為 true,或其中一個(gè)變量為 true"
else:
print "4 - 變量 a 和 b 都不為 true"
if not( a and b ):
print "5 - 變量 a 和 b 都為 false,或其中一個(gè)變量為 false"
else:
print "5 - 變量 a 和 b 都為 true"
in,not in
a = 10
b = 20
list = [1, 2, 3, 4, 5 ];
if ( a in list ):
print "1 - 變量 a 在給定的列表中 list 中"
else:
print "1 - 變量 a 不在給定的列表中 list 中"
if ( b not in list ):
print "2 - 變量 b 不在給定的列表中 list 中"
else:
print "2 - 變量 b 在給定的列表中 list 中"
a = 2
if ( a in list ):
print "3 - 變量 a 在給定的列表中 list 中"
else:
print "3 - 變量 a 不在給定的列表中 list 中"
條件
flag = False
name = 'luren'
if name == 'python': # 判斷變量否為'python'
flag = True # 條件成立時(shí)設(shè)置標(biāo)志為真
print 'welcome boss' # 并輸出歡迎信息
else:
print name
num = 5
if num == 3: # 判斷num的值
print 'boss'
elif num == 2:
print 'user'
elif num == 1:
print 'worker'
elif num 0: # 值小于零時(shí)輸出
print 'error'
else:
print 'roadman' # 條件均不成立時(shí)輸出
循環(huán)語(yǔ)句:
count = 0
while (count 9):
print 'The count is:', count
count = count + 1
print "Good bye!"
i = 1
while i 10:
i += 1
if i%2 0: # 非雙數(shù)時(shí)跳過(guò)輸出
continue
print i # 輸出雙數(shù)2、4、6、8、10
i = 1
while 1: # 循環(huán)條件為1必定成立
print i # 輸出1~10
i += 1
if i 10: # 當(dāng)i大于10時(shí)跳出循環(huán)
break
for letter in 'Python': # 第一個(gè)實(shí)例
print '當(dāng)前字母 :', letter
fruits = ['banana', 'apple', 'mango']
for fruit in fruits: # 第二個(gè)實(shí)例
print '當(dāng)前水果 :', fruit
print "Good bye!"
獲取用戶(hù)輸入:raw_input
var = 1
while var == 1 : # 該條件永遠(yuǎn)為true,循環(huán)將無(wú)限執(zhí)行下去
num = raw_input("Enter a number :")
print "You entered: ", num
print "Good bye!"
range,len
fruits = ['banana', 'apple', 'mango']
for index in range(len(fruits)):
print '當(dāng)前水果 :', fruits[index]
print "Good bye!"
python數(shù)學(xué)函數(shù):
abs,cell,cmp,exp,fabs,floor,log,log10,max,min,mod,pow,round,sqrt
randrange
訪問(wèn)字符串的值
var1 = 'Hello World!'
var2 = "Python Runoob"
print "var1[0]: ", var1[0]
print "var2[1:5]: ", var2[1:5]
轉(zhuǎn)義字符
格式化輸出
print "My name is %s and weight is %d kg!" % ('Zara', 21)
字符串函數(shù):
添加元素
list = [] ## 空列表
list.append('Google') ## 使用 append() 添加元素
list.append('Runoob')
print list
刪除元素
list1 = ['physics', 'chemistry', 1997, 2000]
print list1
del list1[2]
print "After deleting value at index 2 : "
print list1
列表操作
列表方法
刪除字典
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'};
del dict['Name']; # 刪除鍵是'Name'的條目
dict.clear(); # 清空詞典所有條目
del dict ; # 刪除詞典
print "dict['Age']: ", dict['Age'];
print "dict['School']: ", dict['School'];
字典的函數(shù):
當(dāng)前時(shí)間戳:
import time
time.time()
格式化日期輸出
import time
print time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print time.strftime("%a %b %d %H:%M:%S %Y", time.localtime())
a = "Sat Mar 28 22:24:24 2016"
print time.mktime(time.strptime(a,"%a %b %d %H:%M:%S %Y"))
獲取某個(gè)月日歷:calendar
import calendar
cal = calendar.month(2016, 1)
print "以下輸出2016年1月份的日歷:"
print cal
當(dāng)前日期和時(shí)間
import datetime
i = datetime.datetime.now()
print ("當(dāng)前的日期和時(shí)間是 %s" % i)
print ("ISO格式的日期和時(shí)間是 %s" % i.isoformat() )
print ("當(dāng)前的年份是 %s" %i.year)
print ("當(dāng)前的月份是 %s" %i.month)
print ("當(dāng)前的日期是 %s" %i.day)
print ("dd/mm/yyyy 格式是 %s/%s/%s" % (i.day, i.month, i.year) )
print ("當(dāng)前小時(shí)是 %s" %i.hour)
print ("當(dāng)前分鐘是 %s" %i.minute)
print ("當(dāng)前秒是 %s" %i.second)
不定長(zhǎng)參數(shù):*
lambda:匿名函數(shù)
def....
python模塊搜索路徑
獲取用戶(hù)輸入
str = raw_input("請(qǐng)輸入:")
print "你輸入的內(nèi)容是: ", str
input可以接收表達(dá)式
open參數(shù)
write要自己添加換行符
讀取10個(gè)字符
重命名:os.rename
os.remove
os.mkdir os.chdir
os.getcwd
os.rmdir
open參數(shù)
file的方法
異常:
try:
fh = open("testfile", "w")
fh.write("這是一個(gè)測(cè)試文件,用于測(cè)試異常!!")
except IOError:
print "Error: 沒(méi)有找到文件或讀取文件失敗"
else:
print "內(nèi)容寫(xiě)入文件成功"
fh.close()
try:
fh = open("testfile", "w")
fh.write("這是一個(gè)測(cè)試文件,用于測(cè)試異常!!")
finally:
print "Error: 沒(méi)有找到文件或讀取文件失敗"
用戶(hù)自定義異常:
os 模塊提供了非常豐富的方法用來(lái)處理文件和目錄。常用的方法如下表所示:
| 序號(hào) | 方法及描述 |
| 1 |
os.access(path, mode)
檢驗(yàn)權(quán)限模式 |
| 2 |
os.chdir(path)
改變當(dāng)前工作目錄 |
| 3 |
os.chflags(path, flags)
設(shè)置路徑的標(biāo)記為數(shù)字標(biāo)記。 |
| 4 |
os.chmod(path, mode)
更改權(quán)限 |
| 5 |
os.chown(path, uid, gid)
更改文件所有者 |
| 6 |
os.chroot(path)
改變當(dāng)前進(jìn)程的根目錄 |
| 7 |
os.close(fd)
關(guān)閉文件描述符 fd |
| 8 |
os.closerange(fd_low, fd_high)
關(guān)閉所有文件描述符,從 fd_low (包含) 到 fd_high (不包含), 錯(cuò)誤會(huì)忽略 |
| 9 |
os.dup(fd)
復(fù)制文件描述符 fd |
| 10 |
os.dup2(fd, fd2)
將一個(gè)文件描述符 fd 復(fù)制到另一個(gè) fd2 |
| 11 |
os.fchdir(fd)
通過(guò)文件描述符改變當(dāng)前工作目錄 |
| 12 |
os.fchmod(fd, mode)
改變一個(gè)文件的訪問(wèn)權(quán)限,該文件由參數(shù)fd指定,參數(shù)mode是Unix下的文件訪問(wèn)權(quán)限。 |
| 13 |
os.fchown(fd, uid, gid)
修改一個(gè)文件的所有權(quán),這個(gè)函數(shù)修改一個(gè)文件的用戶(hù)ID和用戶(hù)組ID,該文件由文件描述符fd指定。 |
| 14 |
os.fdatasync(fd)
強(qiáng)制將文件寫(xiě)入磁盤(pán),該文件由文件描述符fd指定,但是不強(qiáng)制更新文件的狀態(tài)信息。 |
| 15 |
os.fdopen(fd[, mode[, bufsize]])
通過(guò)文件描述符 fd 創(chuàng)建一個(gè)文件對(duì)象,并返回這個(gè)文件對(duì)象 |
| 16 |
os.fpathconf(fd, name)
返回一個(gè)打開(kāi)的文件的系統(tǒng)配置信息。name為檢索的系統(tǒng)配置的值,它也許是一個(gè)定義系統(tǒng)值的字符串,這些名字在很多標(biāo)準(zhǔn)中指定(POSIX.1, Unix 95, Unix 98, 和其它)。 |
| 17 |
os.fstat(fd)
返回文件描述符fd的狀態(tài),像stat()。 |
| 18 |
os.fstatvfs(fd)
返回包含文件描述符fd的文件的文件系統(tǒng)的信息,像 statvfs() |
| 19 |
os.fsync(fd)
強(qiáng)制將文件描述符為fd的文件寫(xiě)入硬盤(pán)。 |
| 20 |
os.ftruncate(fd, length)
裁剪文件描述符fd對(duì)應(yīng)的文件, 所以它最大不能超過(guò)文件大小。 |
| 21 |
os.getcwd()
返回當(dāng)前工作目錄 |
| 22 |
os.getcwdu()
返回一個(gè)當(dāng)前工作目錄的Unicode對(duì)象 |
| 23 |
os.isatty(fd)
如果文件描述符fd是打開(kāi)的,同時(shí)與tty(-like)設(shè)備相連,則返回true, 否則False。 |
| 24 |
os.lchflags(path, flags)
設(shè)置路徑的標(biāo)記為數(shù)字標(biāo)記,類(lèi)似 chflags(),但是沒(méi)有軟鏈接 |
| 25 |
os.lchmod(path, mode)
修改連接文件權(quán)限 |
| 26 |
os.lchown(path, uid, gid)
更改文件所有者,類(lèi)似 chown,但是不追蹤鏈接。 |
| 27 |
os.link(src, dst)
創(chuàng)建硬鏈接,名為參數(shù) dst,指向參數(shù) src |
| 28 |
os.listdir(path)
返回path指定的文件夾包含的文件或文件夾的名字的列表。 |
| 29 |
os.lseek(fd, pos, how)
設(shè)置文件描述符 fd當(dāng)前位置為pos, how方式修改: SEEK_SET 或者 0 設(shè)置從文件開(kāi)始的計(jì)算的pos; SEEK_CUR或者 1 則從當(dāng)前位置計(jì)算; os.SEEK_END或者2則從文件尾部開(kāi)始. 在unix,Windows中有效 |
| 30 |
os.lstat(path)
像stat(),但是沒(méi)有軟鏈接 |
| 31 |
os.major(device)
從原始的設(shè)備號(hào)中提取設(shè)備major號(hào)碼 (使用stat中的st_dev或者st_rdev field)。 |
| 32 |
os.makedev(major, minor)
以major和minor設(shè)備號(hào)組成一個(gè)原始設(shè)備號(hào) |
| 33 |
os.makedirs(path[, mode])
遞歸文件夾創(chuàng)建函數(shù)。像mkdir(), 但創(chuàng)建的所有intermediate-level文件夾需要包含子文件夾。 |
| 34 |
os.minor(device)
從原始的設(shè)備號(hào)中提取設(shè)備minor號(hào)碼 (使用stat中的st_dev或者st_rdev field )。 |
| 35 |
os.mkdir(path[, mode])
以數(shù)字mode的mode創(chuàng)建一個(gè)名為path的文件夾.默認(rèn)的 mode 是 0777 (八進(jìn)制)。 |
| 36 |
os.mkfifo(path[, mode])
創(chuàng)建命名管道,mode 為數(shù)字,默認(rèn)為 0666 (八進(jìn)制) |
| 37 |
os.mknod(filename[, mode=0600, device])
創(chuàng)建一個(gè)名為filename文件系統(tǒng)節(jié)點(diǎn)(文件,設(shè)備特別文件或者命名pipe)。
|
| 38 |
os.open(file, flags[, mode])
打開(kāi)一個(gè)文件,并且設(shè)置需要的打開(kāi)選項(xiàng),mode參數(shù)是可選的 |
| 39 |
os.openpty()
打開(kāi)一個(gè)新的偽終端對(duì)。返回 pty 和 tty的文件描述符。 |
| 40 |
os.pathconf(path, name)
返回相關(guān)文件的系統(tǒng)配置信息。 |
| 41 |
os.pipe()
創(chuàng)建一個(gè)管道. 返回一對(duì)文件描述符(r, w) 分別為讀和寫(xiě) |
| 42 |
os.popen(command[, mode[, bufsize]])
從一個(gè) command 打開(kāi)一個(gè)管道 |
| 43 |
os.read(fd, n)
從文件描述符 fd 中讀取最多 n 個(gè)字節(jié),返回包含讀取字節(jié)的字符串,文件描述符 fd對(duì)應(yīng)文件已達(dá)到結(jié)尾, 返回一個(gè)空字符串。 |
| 44 |
os.readlink(path)
返回軟鏈接所指向的文件 |
| 45 |
os.remove(path)
刪除路徑為path的文件。如果path 是一個(gè)文件夾,將拋出OSError; 查看下面的rmdir()刪除一個(gè) directory。 |
| 46 |
os.removedirs(path)
遞歸刪除目錄。 |
| 47 |
os.rename(src, dst)
重命名文件或目錄,從 src 到 dst |
| 48 |
os.renames(old, new)
遞歸地對(duì)目錄進(jìn)行更名,也可以對(duì)文件進(jìn)行更名。 |
| 49 |
os.rmdir(path)
刪除path指定的空目錄,如果目錄非空,則拋出一個(gè)OSError異常。 |
| 50 |
os.stat(path)
獲取path指定的路徑的信息,功能等同于C API中的stat()系統(tǒng)調(diào)用。 |
| 51 |
os.stat_float_times([newvalue])
決定stat_result是否以float對(duì)象顯示時(shí)間戳
|
| 52 |
os.statvfs(path)
獲取指定路徑的文件系統(tǒng)統(tǒng)計(jì)信息 |
| 53 |
os.symlink(src, dst)
創(chuàng)建一個(gè)軟鏈接 |
| 54 |
os.tcgetpgrp(fd)
返回與終端fd(一個(gè)由os.open()返回的打開(kāi)的文件描述符)關(guān)聯(lián)的進(jìn)程組 |
| 55 |
os.tcsetpgrp(fd, pg)
設(shè)置與終端fd(一個(gè)由os.open()返回的打開(kāi)的文件描述符)關(guān)聯(lián)的進(jìn)程組為pg。 |
| 56 |
os.tempnam([dir[, prefix]])
返回唯一的路徑名用于創(chuàng)建臨時(shí)文件。 |
| 57 |
os.tmpfile()
返回一個(gè)打開(kāi)的模式為(w+b)的文件對(duì)象 .這文件對(duì)象沒(méi)有文件夾入口,沒(méi)有文件描述符,將會(huì)自動(dòng)刪除。 |
| 58 |
os.tmpnam()
為創(chuàng)建一個(gè)臨時(shí)文件返回一個(gè)唯一的路徑 |
| 59 |
os.ttyname(fd)
返回一個(gè)字符串,它表示與文件描述符fd 關(guān)聯(lián)的終端設(shè)備。如果fd 沒(méi)有與終端設(shè)備關(guān)聯(lián),則引發(fā)一個(gè)異常。 |
| 60 |
os.unlink(path)
刪除文件路徑 |
| 61 |
os.utime(path, times)
返回指定的path文件的訪問(wèn)和修改的時(shí)間。 |
| 62 |
os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])
輸出在文件夾中的文件名通過(guò)在樹(shù)中游走,向上或者向下。 |
| 63 |
os.write(fd, str)
寫(xiě)入字符串到文件描述符 fd中. 返回實(shí)際寫(xiě)入的字符串長(zhǎng)度 |
1、函數(shù)定義
①使用def關(guān)鍵字定義函數(shù)
②
def 函數(shù)名(參數(shù)1.參數(shù)2.參數(shù)3...):
"""文檔字符串,docstring,用來(lái)說(shuō)明函數(shù)的作用"""
#函數(shù)體
return 表達(dá)式
注釋的作用:說(shuō)明函數(shù)是做什么的,函數(shù)有什么功能。
③遇到冒號(hào)要縮進(jìn),冒號(hào)后面所有的縮進(jìn)的代碼塊構(gòu)成了函數(shù)體,描述了函數(shù)是做什么的,即函數(shù)的功能是什么。Python函數(shù)的本質(zhì)與數(shù)學(xué)中的函數(shù)的本質(zhì)是一致的。
2、函數(shù)調(diào)用
①函數(shù)必須先定義,才能調(diào)用,否則會(huì)報(bào)錯(cuò)。
②無(wú)參數(shù)時(shí)函數(shù)的調(diào)用:函數(shù)名(),有參數(shù)時(shí)函數(shù)的調(diào)用:函數(shù)名(參數(shù)1.參數(shù)2.……)
③不要在定義函數(shù)的時(shí)候在函數(shù)體里面調(diào)用本身,否則會(huì)出不來(lái),陷入循環(huán)調(diào)用。
④函數(shù)需要調(diào)用函數(shù)體才會(huì)被執(zhí)行,單純的只是定義函數(shù)是不會(huì)被執(zhí)行的。
⑤Debug工具中Step into進(jìn)入到調(diào)用的函數(shù)里,Step Into My Code進(jìn)入到調(diào)用的模塊里函數(shù)。
Python math 庫(kù)提供許多對(duì)浮點(diǎn)數(shù)的數(shù)學(xué)運(yùn)算函數(shù),math模塊不支持復(fù)數(shù)運(yùn)算,若需計(jì)算復(fù)數(shù),可使用cmath模塊(本文不贅述)。
使用dir函數(shù),查看math庫(kù)中包含的所有內(nèi)容:
1) math.pi????# 圓周率π
2) math.e????#自然對(duì)數(shù)底數(shù)
3) math.inf? ? #正無(wú)窮大∞,-math.inf? ? #負(fù)無(wú)窮大-∞
4) math.nan? ? #非浮點(diǎn)數(shù)標(biāo)記,NaN(not a number)
1) math.fabs(x)? ? #表示X值的絕對(duì)值
2) math.fmod(x,y)? ? #表示x/y的余數(shù),結(jié)果為浮點(diǎn)數(shù)
3) math.fsum([x,y,z])? ? #對(duì)括號(hào)內(nèi)每個(gè)元素求和,其值為浮點(diǎn)數(shù)
4) math.ceil(x)? ? #向上取整,返回不小于x的最小整數(shù)
5)math.floor(x)? ? #向下取整,返回不大于x的最大整數(shù)
6) math.factorial(x)? ? #表示X的階乘,其中X值必須為整型,否則報(bào)錯(cuò)
7) math.gcd(a,b)? ? #表示a,b的最大公約數(shù)
8)? math.frexp(x)? ? ? #x = i *2^j,返回(i,j)
9) math.ldexp(x,i)? ? #返回x*2^i的運(yùn)算值,為math.frexp(x)函數(shù)的反運(yùn)算
10) math.modf(x)? ? #表示x的小數(shù)和整數(shù)部分
11) math.trunc(x)? ? #表示x值的整數(shù)部分
12) math.copysign(x,y)? ? #表示用數(shù)值y的正負(fù)號(hào),替換x值的正負(fù)號(hào)
13) math.isclose(a,b,rel_tol =x,abs_tol = y)? ? #表示a,b的相似性,真值返回True,否則False;rel_tol是相對(duì)公差:表示a,b之間允許的最大差值,abs_tol是最小絕對(duì)公差,對(duì)比較接近于0有用,abs_tol必須至少為0。
14) math.isfinite(x)? ? #表示當(dāng)x不為無(wú)窮大時(shí),返回True,否則返回False
15) math.isinf(x)? ? #當(dāng)x為±∞時(shí),返回True,否則返回False
16) math.isnan(x)? ? #當(dāng)x是NaN,返回True,否則返回False
1) math.pow(x,y)? ? #表示x的y次冪
2) math.exp(x)? ? #表示e的x次冪
3) math.expm1(x)? ? #表示e的x次冪減1
4) math.sqrt(x)? ? #表示x的平方根
5) math.log(x,base)? ? #表示x的對(duì)數(shù)值,僅輸入x值時(shí),表示ln(x)函數(shù)
6) math.log1p(x)? ? #表示1+x的自然對(duì)數(shù)值
7) math.log2(x)? ? #表示以2為底的x對(duì)數(shù)值
8) math.log10(x)? ? #表示以10為底的x的對(duì)數(shù)值
1) math.degrees(x)? ? #表示弧度值轉(zhuǎn)角度值
2) math.radians(x)? ? #表示角度值轉(zhuǎn)弧度值
3) math.hypot(x,y)? ? #表示(x,y)坐標(biāo)到原點(diǎn)(0,0)的距離
4) math.sin(x)? ? #表示x的正弦函數(shù)值
5) math.cos(x)? ? #表示x的余弦函數(shù)值
6) math.tan(x)? ? #表示x的正切函數(shù)值
7)math.asin(x)? ? #表示x的反正弦函數(shù)值
8)?math.acos(x)? ? #表示x的反余弦函數(shù)值
9)?math.atan(x)? ? #表示x的反正切函數(shù)值
10) math.atan2(y,x)? ? #表示y/x的反正切函數(shù)值
11) math.sinh(x)? ? #表示x的雙曲正弦函數(shù)值
12) math.cosh(x)? ? #表示x的雙曲余弦函數(shù)值
13) math.tanh(x)? ? #表示x的雙曲正切函數(shù)值
14) math.asinh(x)? ? #表示x的反雙曲正弦函數(shù)值
15) math.acosh(x)? ? #表示x的反雙曲余弦函數(shù)值
16) math.atanh(x)? ? #表示x的反雙曲正切函數(shù)值
1)math.erf(x)? ? #高斯誤差函數(shù)
2) math.erfc(x)? ? #余補(bǔ)高斯誤差函數(shù)
3) math.gamma(x)? ? #伽馬函數(shù)(歐拉第二積分函數(shù))
4) math.lgamma(x)? ? #伽馬函數(shù)的自然對(duì)數(shù)
點(diǎn)擊上方 "Python人工智能技術(shù)" 關(guān)注,星標(biāo)或者置頂
22點(diǎn)24分準(zhǔn)時(shí)推送,第一時(shí)間送達(dá)
后臺(tái)回復(fù)“大禮包”,送你特別福利
編輯:樂(lè)樂(lè) | 來(lái)自:pypypypy
上一篇:
正文
大家好,我是Pythn人工智能技術(shù)。
內(nèi)置函數(shù)就是Python給你提供的,拿來(lái)直接用的函數(shù),比如print.,input等。
截止到python版本3.6.2 ,python一共提供了68個(gè)內(nèi)置函數(shù),具體如下
abs() dict() help() min() setattr()
all() dir() hex() next() slice()
any() divmod() id() object() sorted()
ascii() enumerate() input() oct() staticmethod()
bin() eval() int() open() str()
bool() exec() isinstance() ord() sum()
bytearray() ?lter() issubclass() pow() super()
bytes() ?oat() iter() print() tuple()
callable() format() len() property() type()
chr() frozenset() list() range() vars()
classmethod() getattr() locals() repr() zip()
compile() globals() map() reversed() __import__()
complex() hasattr() max() round()
delattr() hash() memoryview() set()
本文將這68個(gè)內(nèi)置函數(shù)綜合整理為12大類(lèi),正在學(xué)習(xí)Python基礎(chǔ)的讀者一定不要錯(cuò)過(guò),建議收藏學(xué)習(xí)!
和數(shù)字相關(guān) 1. 數(shù)據(jù)類(lèi)型
bool : 布爾型(True,False)
int : 整型(整數(shù))
float : 浮點(diǎn)型(小數(shù))
complex : 復(fù)數(shù)
2. 進(jìn)制轉(zhuǎn)換
bin() 將給的參數(shù)轉(zhuǎn)換成二進(jìn)制
otc() 將給的參數(shù)轉(zhuǎn)換成八進(jìn)制
hex() 將給的參數(shù)轉(zhuǎn)換成十六進(jìn)制
print(bin(10)) # 二進(jìn)制:0b1010
print(hex(10)) # 十六進(jìn)制:0xa
print(oct(10)) # 八進(jìn)制:0o12
3. 數(shù)學(xué)運(yùn)算
abs() 返回絕對(duì)值
divmode() 返回商和余數(shù)
round() 四舍五入
pow(a, b) 求a的b次冪, 如果有三個(gè)參數(shù). 則求完次冪后對(duì)第三個(gè)數(shù)取余
sum() 求和
min() 求最小值
max() 求最大值
print(abs(-2)) # 絕對(duì)值:2
print(divmod(20,3)) # 求商和余數(shù):(6,2)
print(round(4.50)) # 五舍六入:4
print(round(4.51)) #5
print(pow(10,2,3)) # 如果給了第三個(gè)參數(shù). 表示最后取余:1
print(sum([1,2,3,4,5,6,7,8,9,10])) # 求和:55
print(min(5,3,9,12,7,2)) #求最小值:2
print(max(7,3,15,9,4,13)) #求最大值:15
和數(shù)據(jù)結(jié)構(gòu)相關(guān) 1. 序列
(1)列表和元組
list() 將一個(gè)可迭代對(duì)象轉(zhuǎn)換成列表
tuple() 將一個(gè)可迭代對(duì)象轉(zhuǎn)換成元組
print(list((1,2,3,4,5,6))) #[1, 2, 3, 4, 5, 6]
print(tuple([1,2,3,4,5,6])) #(1, 2, 3, 4, 5, 6)
(2)相關(guān)內(nèi)置函數(shù)
reversed() 將一個(gè)序列翻轉(zhuǎn), 返回翻轉(zhuǎn)序列的迭代器
slice() 列表的切片
lst = "你好啊"
it = reversed(lst) # 不會(huì)改變?cè)斜? 返回一個(gè)迭代器, 設(shè)計(jì)上的一個(gè)規(guī)則
print(list(it)) #['啊', '好', '你']
lst = [1, 2, 3, 4, 5, 6, 7]
print(lst[1:3:1]) #[2,3]
s = slice(1, 3, 1) # 切片用的
print(lst[s]) #[2,3]
(3)字符串
str() 將數(shù)據(jù)轉(zhuǎn)化成字符串
print(str(123)+'456') #123456
format() 與具體數(shù)據(jù)相關(guān), 用于計(jì)算各種小數(shù), 精算等.
s = "hello world!"
print(format(s, "^20")) #劇中
print(format(s, "20")) #左對(duì)齊
print(format(s, "20")) #右對(duì)齊
# hello world!
# hello world!
# hello world!
print(format(3, 'b' )) # 二進(jìn)制:11
print(format(97, 'c' )) # 轉(zhuǎn)換成unicode字符:a
print(format(11, 'd' )) # ?進(jìn)制:11
print(format(11, 'o' )) # 八進(jìn)制:13
print(format(11, 'x' )) # 十六進(jìn)制(?寫(xiě)字母):b
print(format(11, 'X' )) # 十六進(jìn)制(大寫(xiě)字母):B
print(format(11, 'n' )) # 和d?樣:11
print(format(11)) # 和d?樣:11
print(format(123456789, 'e' )) # 科學(xué)計(jì)數(shù)法. 默認(rèn)保留6位小數(shù):1.234568e+08
print(format(123456789, '0.2e' )) # 科學(xué)計(jì)數(shù)法. 保留2位小數(shù)(小寫(xiě)):1.23e+08
print(format(123456789, '0.2E' )) # 科學(xué)計(jì)數(shù)法. 保留2位小數(shù)(大寫(xiě)):1.23E+08
print(format(1.23456789, 'f' )) # 小數(shù)點(diǎn)計(jì)數(shù)法. 保留6位小數(shù):1.234568
print(format(1.23456789, '0.2f' )) # 小數(shù)點(diǎn)計(jì)數(shù)法. 保留2位小數(shù):1.23
print(format(1.23456789, '0.10f')) # 小數(shù)點(diǎn)計(jì)數(shù)法. 保留10位小數(shù):1.2345678900
print(format(1.23456789e+3, 'F')) # 小數(shù)點(diǎn)計(jì)數(shù)法. 很大的時(shí)候輸出INF:1234.567890
bytes() 把字符串轉(zhuǎn)化成bytes類(lèi)型
bs = bytes("今天吃飯了嗎", encoding="utf-8")
print(bs) #b'\xe4\xbb\x8a\xe5\xa4\xa9\xe5\x90\x83\xe9\xa5\xad\xe4\xba\x86\xe5\x90\x97'
bytearray() 返回一個(gè)新字節(jié)數(shù)組. 這個(gè)數(shù)字的元素是可變的, 并且每個(gè)元素的值得范圍是[0,256)
ret = bytearray("alex" ,encoding ='utf-8')
print(ret[0]) #97
print(ret) #bytearray(b'alex')
ret[0] = 65 #把65的位置A賦值給ret[0]
print(str(ret)) #bytearray(b'Alex')
ord() 輸入字符找?guī)ё址幋a的位置
chr() 輸入位置數(shù)字找出對(duì)應(yīng)的字符
ascii() 是ascii碼中的返回該值 不是就返回u
print(ord('a')) # 字母a在編碼表中的碼位:97
print(ord('中')) # '中'字在編碼表中的位置:20013
print(chr(65)) # 已知碼位,求字符是什么:A
print(chr(19999)) #丟
for i in range(65536): #打印出0到65535的字符
print(chr(i), end=" ")
print(ascii("@")) #'@'
repr() 返回一個(gè)對(duì)象的string形式
s = "今天\n吃了%s頓\t飯" % 3
print(s)#今天# 吃了3頓 飯
print(repr(s)) # 原樣輸出,過(guò)濾掉轉(zhuǎn)義字符 \n \t \r 不管百分號(hào)%
#'今天\n吃了3頓\t飯'
2. 數(shù)據(jù)集合
字典:dict 創(chuàng)建一個(gè)字典
集合:set 創(chuàng)建一個(gè)集合
frozenset() 創(chuàng)建一個(gè)凍結(jié)的集合,凍結(jié)的集合不能進(jìn)行添加和刪除操作。
3. 相關(guān)內(nèi)置函數(shù)
len() 返回一個(gè)對(duì)象中的元素的個(gè)數(shù)
sorted() 對(duì)可迭代對(duì)象進(jìn)行排序操作 (lamda)
語(yǔ)法:sorted(Iterable, key=函數(shù)(排序規(guī)則), reverse=False)
Iterable: 可迭代對(duì)象
key: 排序規(guī)則(排序函數(shù)), 在sorted內(nèi)部會(huì)將可迭代對(duì)象中的每一個(gè)元素傳遞給這個(gè)函數(shù)的參數(shù). 根據(jù)函數(shù)運(yùn)算的結(jié)果進(jìn)行排序
reverse: 是否是倒敘. True: 倒敘, False: 正序
lst = [5,7,6,12,1,13,9,18,5]
lst.sort() # sort是list里面的一個(gè)方法
print(lst) #[1, 5, 5, 6, 7, 9, 12, 13, 18]
ll = sorted(lst) # 內(nèi)置函數(shù). 返回給你一個(gè)新列表 新列表是被排序的
print(ll) #[1, 5, 5, 6, 7, 9, 12, 13, 18]
l2 = sorted(lst,reverse=True) #倒序
print(l2) #[18, 13, 12, 9, 7, 6, 5, 5, 1]
#根據(jù)字符串長(zhǎng)度給列表排序
lst = ['one', 'two', 'three', 'four', 'five', 'six']
def f(s):
return len(s)
l1 = sorted(lst, key=f, )
print(l1) #['one', 'two', 'six', 'four', 'five', 'three']
enumerate() 獲取集合的枚舉對(duì)象
lst = ['one','two','three','four','five']
for index, el in enumerate(lst,1): # 把索引和元素一起獲取,索引默認(rèn)從0開(kāi)始. 可以更改
print(index)
print(el)
# 1
# one
# 2
# two
# 3
# three
# 4
# four
# 5
# five
all() 可迭代對(duì)象中全部是True, 結(jié)果才是True
any() 可迭代對(duì)象中有一個(gè)是True, 結(jié)果就是True
print(all([1,'hello',True,9])) #True
print(any([0,0,0,False,1,'good'])) #True
zip() 函數(shù)用于將可迭代的對(duì)象作為參數(shù), 將對(duì)象中對(duì)應(yīng)的元素打包成一個(gè)元組, 然后返回由這些元組組成的列表. 如果各個(gè)迭代器的元素個(gè)數(shù)不一致, 則返回列表長(zhǎng)度與最短的對(duì)象相同
lst1 = [1, 2, 3, 4, 5, 6]
lst2 = ['醉鄉(xiāng)民謠', '驢得水', '放牛班的春天', '美麗人生', '辯護(hù)人', '被嫌棄的松子的一生']
lst3 = ['美國(guó)', '中國(guó)', '法國(guó)', '意大利', '韓國(guó)', '日本']
print(zip(lst1, lst1, lst3)) #
for el in zip(lst1, lst2, lst3):
print(el)
# (1, '醉鄉(xiāng)民謠', '美國(guó)')
# (2, '驢得水', '中國(guó)')
# (3, '放牛班的春天', '法國(guó)')
# (4, '美麗人生', '意大利')
# (5, '辯護(hù)人', '韓國(guó)')
# (6, '被嫌棄的松子的一生', '日本')
fiter() 過(guò)濾 (lamda)
語(yǔ)法:fiter(function. Iterable)
function: 用來(lái)篩選的函數(shù). 在?lter中會(huì)自動(dòng)的把iterable中的元素傳遞給function. 然后根據(jù)function返回的True或者False來(lái)判斷是否保留留此項(xiàng)數(shù)據(jù) , Iterable: 可迭代對(duì)象
搜索公眾號(hào)頂級(jí)架構(gòu)師后臺(tái)回復(fù)“面試”,送你一份驚喜禮包。
def func(i): # 判斷奇數(shù)
return i % 2 == 1
lst = [1,2,3,4,5,6,7,8,9]
l1 = filter(func, lst) #l1是迭代器
print(l1) #
print(list(l1)) #[1, 3, 5, 7, 9]
map() 會(huì)根據(jù)提供的函數(shù)對(duì)指定序列列做映射(lamda)
語(yǔ)法 : map(function, iterable)
可以對(duì)可迭代對(duì)象中的每一個(gè)元素進(jìn)行映射. 分別去執(zhí)行 function
def f(i): return i
lst = [1,2,3,4,5,6,7,]
it = map(f, lst) # 把可迭代對(duì)象中的每一個(gè)元素傳遞給前面的函數(shù)進(jìn)行處理. 處理的結(jié)果會(huì)返回成迭代器print(list(it)) #[1, 2, 3, 4, 5, 6, 7]
和作用域相關(guān)
locals() 返回當(dāng)前作用域中的名字
globals() 返回全局作用域中的名字
def func():
a = 10
print(locals()) # 當(dāng)前作用域中的內(nèi)容
print(globals()) # 全局作用域中的內(nèi)容
print("今天內(nèi)容很多")
func()
# {'a': 10}
# {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__':
# _frozen_importlib_external.SourceFileLoader object at 0x0000026F8D566080,
# '__spec__': None, '__annotations__': {}, '__builtins__':
# (built-in), '__file__': 'D:/pycharm/練習(xí)/week03/new14.py', '__cached__': None,
# 'func': }
# 今天內(nèi)容很多
和迭代器生成器相關(guān)
range() 生成數(shù)據(jù)
next() 迭代器向下執(zhí)行一次, 內(nèi)部實(shí)際使?用了__ next__()?方法返回迭代器的下一個(gè)項(xiàng)目
iter() 獲取迭代器, 內(nèi)部實(shí)際使用的是__ iter__()?方法來(lái)獲取迭代器
for i in range(15,-1,-5):
print(i)
# 15
# 10
# 5
# 0
lst = [1,2,3,4,5]
it = iter(lst) # __iter__()獲得迭代器
print(it.__next__()) #1
print(next(it)) #2 __next__()
print(next(it)) #3
print(next(it)) #4
字符串類(lèi)型代碼的執(zhí)行
eval() 執(zhí)行字符串類(lèi)型的代碼. 并返回最終結(jié)果
exec() 執(zhí)行字符串類(lèi)型的代碼
compile() 將字符串類(lèi)型的代碼編碼. 代碼對(duì)象能夠通過(guò)exec語(yǔ)句來(lái)執(zhí)行或者eval()進(jìn)行求值
s1 = input("請(qǐng)輸入a+b:") #輸入:8+9
print(eval(s1)) # 17 可以動(dòng)態(tài)的執(zhí)行代碼. 代碼必須有返回值
s2 = "for i in range(5): print(i)"
a = exec(s2) # exec 執(zhí)行代碼不返回任何內(nèi)容
# 0
# 1
# 2
# 3
# 4
print(a) #None
# 動(dòng)態(tài)執(zhí)行代碼
exec("""
def func():
print(" 我是周杰倫")
""" )
func() #我是周杰倫
code1 = "for i in range(3): print(i)"
com = compile(code1, "", mode="exec") # compile并不會(huì)執(zhí)行你的代碼.只是編譯
exec(com) # 執(zhí)行編譯的結(jié)果
# 0
# 1
# 2
code2 = "5+6+7"
com2 = compile(code2, "", mode="eval")
print(eval(com2)) # 18
code3 = "name = input('請(qǐng)輸入你的名字:')" #輸入:hello
com3 = compile(code3, "", mode="single")
exec(com3)
print(name) #hello
輸入輸出
print() : 打印輸出
input() : 獲取用戶(hù)輸出的內(nèi)容
print("hello", "world", sep="*", end="@") # sep:打印出的內(nèi)容用什么連接,end:以什么為結(jié)尾
#hello*world@
內(nèi)存相關(guān)
hash() : 獲取到對(duì)象的哈希值(int, str, bool, tuple). hash算法:(1) 目的是唯一性 (2) dict 查找效率非常高, hash表.用空間換的時(shí)間 比較耗費(fèi)內(nèi)存
s = 'alex'print(hash(s)) #-168324845050430382lst = [1, 2, 3, 4, 5]print(hash(lst)) #報(bào)錯(cuò),列表是不可哈希的 id() : 獲取到對(duì)象的內(nèi)存地址s = 'alex'print(id(s)) #2278345368944
文件操作相關(guān)
open() : 用于打開(kāi)一個(gè)文件, 創(chuàng)建一個(gè)文件句柄
f = open('file',mode='r',encoding='utf-8')
f.read()
f.close()
模塊相關(guān)
__ import__() : 用于動(dòng)態(tài)加載類(lèi)和函數(shù)
# 讓用戶(hù)輸入一個(gè)要導(dǎo)入的模塊
import os
name = input("請(qǐng)輸入你要導(dǎo)入的模塊:")
__import__(name) # 可以動(dòng)態(tài)導(dǎo)入模塊
幫 助
help() : 函數(shù)用于查看函數(shù)或模塊用途的詳細(xì)說(shuō)明
print(help(str)) #查看字符串的用途
調(diào)用相關(guān)
callable() : 用于檢查一個(gè)對(duì)象是否是可調(diào)用的. 如果返回True, object有可能調(diào)用失敗, 但如果返回False. 那調(diào)用絕對(duì)不會(huì)成功
a = 10
print(callable(a)) #False 變量a不能被調(diào)用
def f():
print("hello")
print(callable(f)) # True 函數(shù)是可以被調(diào)用的
查看內(nèi)置屬性
dir() : 查看對(duì)象的內(nèi)置屬性, 訪問(wèn)的是對(duì)象中的__dir__()方法
print(dir(tuple)) #查看元組的方法
你還有什么想要補(bǔ)充的嗎?
免責(zé)聲明:本文內(nèi)容來(lái)源于網(wǎng)絡(luò),文章版權(quán)歸原作者所有,意在傳播相關(guān)技術(shù)知識(shí)行業(yè)趨勢(shì),供大家學(xué)習(xí)交流,若涉及作品版權(quán)問(wèn)題,請(qǐng)聯(lián)系刪除或授權(quán)事宜。
技術(shù)君個(gè)人微信
添加技術(shù)君個(gè)人微信即送一份驚喜大禮包
→ 技術(shù)資料共享
→ 技術(shù)交流社群
--END--
往日熱文:
Python程序員深度學(xué)習(xí)的“四大名著”:
這四本書(shū)著實(shí)很不錯(cuò)!我們都知道現(xiàn)在機(jī)器學(xué)習(xí)、深度學(xué)習(xí)的資料太多了,面對(duì)海量資源,往往陷入到“無(wú)從下手”的困惑出境。而且并非所有的書(shū)籍都是優(yōu)質(zhì)資源,浪費(fèi)大量的時(shí)間是得不償失的。給大家推薦這幾本好書(shū)并做簡(jiǎn)單介紹。
獲得方式:
2.后臺(tái)回復(fù)關(guān)鍵詞:名著
首先,你的語(yǔ)法是 Python3 的語(yǔ)法,但是用的是 Python2;
其實(shí),類(lèi)似這種題目,借助格式化輸出會(huì)更加方便,看代碼:
# -*- encoding: gbk -*-
for row in range(1, 10):
for col in range(1, row + 1):
prod = row * col
print '%d * %d = %-2d ' % (col, row, prod),
Python定義
求余運(yùn)行a % b的值處于開(kāi)區(qū)間[0, b)內(nèi),如果b是負(fù)數(shù),開(kāi)區(qū)間變?yōu)?b, 0]。這是一個(gè)很常見(jiàn)的定義方式。不過(guò)其實(shí)它依賴(lài)于整除的定義。為了讓方程式:b * (a // b) + a % b = a恒真,整除運(yùn)行需要向負(fù)無(wú)窮小方向取值。比如7 // 3的結(jié)果是2,而(-7) // 3的結(jié)果卻是-3。這個(gè)算法與其它很多編程語(yǔ)言不一樣,需要注意,它們的整除運(yùn)算會(huì)向0的方向取值。
以上內(nèi)容參考:百度百科-Python
本文題目:python所有數(shù)學(xué)函數(shù),python數(shù)學(xué)函數(shù)庫(kù)
瀏覽路徑:http://chinadenli.net/article15/dsejodi.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、標(biāo)簽優(yōu)化、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、網(wǎng)站排名、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容