最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

pytest自動(dòng)化測(cè)試中的fixture的聲明和調(diào)用

 更新時(shí)間:2021年10月09日 14:08:53   作者:愛測(cè)試的高胖胖  
這篇文章主要為大家介紹了pytest自動(dòng)化測(cè)試中的fixture的聲明和調(diào)用,文中含有詳細(xì)示例操作有需要的朋友可以借鑒參考下,希望能夠有所幫助

1. fixture的聲明

我們使用@pytest.fixture()來(lái)聲明fixture函數(shù)。fixture()即可無(wú)參數(shù)進(jìn)行聲明,也可以帶參數(shù)聲明。

示例1:

@pytest.fixture()無(wú)參數(shù)進(jìn)行聲明

import pytest
@pytest.fixture      #fixture()未帶任何參數(shù),聲明一個(gè)fixture函數(shù)
def fixture_demo():
    print("這個(gè)是一個(gè)fixture的demo演示")
def test_demo(fixture_demo):  #調(diào)用fixture函數(shù)——fixture_demo
    print("這是一個(gè)測(cè)試demo。")
    

@pytest.fixture()有參數(shù)的進(jìn)行聲明
通過(guò)上文pytest中fixtureAPI簡(jiǎn)單說(shuō)明,我們對(duì)fixture()的參數(shù)有了一定了解。fixture()可以帶著這些參數(shù)去聲明一個(gè)fixture函數(shù)。

import pytest
@pytest.fixture(params=[1,2,3]) #fixture()帶著parmas對(duì)ids()進(jìn)行fixture函數(shù)的聲明
def ids(request):
    data=request.param
    print(f'獲取測(cè)試數(shù)據(jù){data}')
    return data
def test_ids(ids):  #調(diào)用fixture函數(shù)-ids()
    print(ids)

2. fixture的調(diào)用

2.1 fixture的調(diào)用方式

fixture有三種調(diào)用方式,分別為:

1. 使用 fixturename
2. 使用@pytest.mark.usefixtures(“fixturename”)
3. autouse——自動(dòng)應(yīng)用

2.1.1 使用fixturename

通過(guò)pytest中fixtureAPI簡(jiǎn)單說(shuō)明中對(duì)@fixture()參數(shù)的介紹,我們知道fixturename默認(rèn)是@pytest.fixture()所裝飾的函數(shù)的函數(shù)名,如果傳入name參數(shù),則fixturename就是name傳入的內(nèi)容。

當(dāng)要調(diào)用fixture的時(shí)候,只要將fixturename作為參數(shù)傳入測(cè)試函數(shù)即可。

示例2:

1.使用被裝飾的函數(shù)的函數(shù)名

import pytest
@pytest.fixture() #未傳入name,因此fixturename為函數(shù)名login
def login():
    print('login')
def test_case1(login):  #將fixturename作為參數(shù)傳入
    print('這是testcase1')

2.使用fixture別名

import pytest
@pytest.fixture(name='login1') #傳入name,因此fixturename為login1
def login():
    print('login')
def test_case1(login1):  #將fixturename作為參數(shù)傳入
    print('這是testcase1')

注意:
當(dāng)使用fixture的別名后,被裝束函數(shù)的函數(shù)名失效,無(wú)法再繼續(xù)使用其進(jìn)行fixture的調(diào)用。

在這里插入圖片描述

2.1.2 使用@pytest.mark.usefixtures("fixturename")

根據(jù)pytest官方文檔的介紹,如果想讓某個(gè)fixture適用于類、模塊和項(xiàng)目中所有測(cè)試函數(shù)的話,會(huì)使用usefixtures來(lái)調(diào)用fixture。當(dāng)然,單個(gè)測(cè)試函數(shù)也可以使用此方法來(lái)調(diào)用fixture。

使用usefixtures調(diào)用fixture和直接使用fixturename來(lái)調(diào)用fixture是有區(qū)別的,可總結(jié)為:

使用usefixtures調(diào)用的fixture只能用于配置測(cè)試前系統(tǒng)的初始狀態(tài),無(wú)法為測(cè)試用例提供測(cè)試數(shù)據(jù);但使用fixturename調(diào)用的fixture卻可以實(shí)現(xiàn)這兩個(gè)功能。

示例:
1.聲明一個(gè)名為login的fixture,并通過(guò)fixture()傳入測(cè)試數(shù)據(jù)集。test_case1使用usefixtures的方法調(diào)用login,并且在函數(shù)內(nèi)部想要打印login的返回值。

import pytest
@pytest.fixture(params=[1,2,3])  # 傳入測(cè)試數(shù)據(jù)集 
def login(request):
    print("登陸操作")
    return request.param #返回測(cè)試數(shù)據(jù)
class TestClass1:
    @pytest.mark.usefixtures('login')  #使用usefixtures調(diào)用login
    def test_case1(self):
        print("這是Testclass1中testcase1")
        print(login)  #打印login 

運(yùn)行后發(fā)現(xiàn),結(jié)果和我們預(yù)期的不一樣,print(login)打印出的是函數(shù)對(duì)象信息,不是返回值。

在這里插入圖片描述

2.修改剛剛的代碼,使用fixturename來(lái)調(diào)用login

import pytest
@pytest.fixture(params=[1,2,3])  # 傳入測(cè)試數(shù)據(jù)集 
def login(request):
    print("登陸操作")
    return request.param #返回測(cè)試數(shù)據(jù)
class TestClass1:
    #@pytest.mark.usefixtures('login')  #使用usefixtures調(diào)用login
    def test_case1(self,login): #使用fixturename的方式調(diào)用login
        print("這是Testclass1中testcase1")
        print(login)  #打印login

運(yùn)行后我們可以發(fā)現(xiàn),結(jié)果和我們預(yù)期的一致,把login的返回值成功打印出來(lái)。

在這里插入圖片描述

usefixtures調(diào)用fixture的方法只適用于測(cè)試函數(shù),對(duì)于fixture函數(shù)不生效;使用fixturename調(diào)用fixture的方法對(duì)測(cè)試函數(shù)和fixture函數(shù)都適用。

示例:
1.以下demo想要實(shí)現(xiàn)執(zhí)行測(cè)試用例前打印“登陸操作”,用例執(zhí)行結(jié)束后打印“注銷操作”。聲明loginlogout為fixture函數(shù),并且讓logout使用usefixtures的方法調(diào)用login,再讓test_case1調(diào)用logout。

import pytest
@pytest.fixture() 
def login():
    print("登陸操作")
@pytest.mark.usefixtures('login') @pytest.fixture() def logout():
    yield
    print("注銷操作")
class TestClass1:
    def test_case1(self,logout):
        print("這是Testclass1中testcase1") 

通過(guò)運(yùn)行結(jié)果我們發(fā)現(xiàn),結(jié)果只在執(zhí)行測(cè)試函用例后打印了“注銷操作”,與我們預(yù)期的結(jié)果不一致。

在這里插入圖片描述

2.修改上面的demo代碼,讓logout使用fixturename的方式調(diào)用login。

import pytest
@pytest.fixture()
 def login():
    print("登陸操作")
#@pytest.mark.usefixtures('login') 
@pytest.fixture() 
def logout(login): #使用fixturename的方式調(diào)用login
    yield
    print("注銷操作")
class TestClass1:
    def test_case1(self,logout):
        print("這是Testclass1中testcase1") 
        

運(yùn)行后我們發(fā)現(xiàn),結(jié)果與我們預(yù)期的一致。

在這里插入圖片描述

由此可以看出來(lái),userfixtures的調(diào)用方法對(duì)于fixture函數(shù)無(wú)效。

下面我們將通過(guò)示例來(lái)演示userfixtures的使用方法:

為了演示效果,我們新建一個(gè)包,并在里面創(chuàng)建一個(gè)conftest.py。用于定義fixture函數(shù)。關(guān)于conftest.py的相關(guān)內(nèi)容,后面會(huì)單獨(dú)寫一遍文章詳細(xì)介紹。

在這里插入圖片描述

在conftest.py中聲明的一個(gè)login函數(shù)。

import pytest
@pytest.fixture()  
def login():
    print('登錄操作')
    

1.整個(gè)類中應(yīng)用fixture

使用usefixtures,讓TestClass1這個(gè)類中所有測(cè)試函數(shù)都調(diào)用login。

import pytest
@pytest.mark.usefixtures('login')  #讓TestClass1調(diào)用login
class TestClass1:
    def test_case1(self):
        print("這是Testclass1中testcase1")
    def test_case2(self):
        print('這是Testclass1中testcase2')
class TestClass2:
    def test_case3(self):
        print('這是Testclass2中的testcase3')

運(yùn)行結(jié)果:

通過(guò)結(jié)果我們可以發(fā)現(xiàn),只有TestClass1中的test_case1和test_case2調(diào)用了login。

在這里插入圖片描述

2.整個(gè)模塊應(yīng)用fixture

根據(jù)官方文檔說(shuō)明,在整個(gè)模塊中應(yīng)用fixture,可在模塊使用

pytestmark=pytest.mark.usefixtures("fixturename")。

修改測(cè)試代碼如下:

import pytest
pytestmark = pytest.mark.usefixtures("login")  #使用pytestmark在模塊中使用usefixtures
class TestClass1:
    def test_case1(self):
        print("這是Testclass1中testcase1")
    def test_case2(self):
        print('這是Testclass1中testcase2')
class TestClass2:
    def test_case3(self):
        print('這是Testclass2中的testcase3')

運(yùn)行結(jié)果:

通過(guò)運(yùn)行結(jié)果可發(fā)現(xiàn),整個(gè)模塊中,所有測(cè)試類里面的測(cè)試函數(shù)都調(diào)用了login。

在這里插入圖片描述

3.整個(gè)項(xiàng)目中使用

pytest.ini中配置usefixtures。

演示項(xiàng)目結(jié)構(gòu)如圖:

在這里插入圖片描述

對(duì)應(yīng)文件中的代碼如下:

test_demo中的test_demo.py

class TestClass1:
    def test_case1(self):
        print("這是pytest_demo包中test_demo模塊里Testclass1中testcase1")
class TestClass2:
    def test_case2(self):
        print('這是pytest_demo包中test_demo模塊里Testclass2中的testcase2')

test_usefixtures中的test_usefixtures.py

class TestClass1:
    def test_case1(self):
        print("這是pytest_usefixtures包中test_usefixtures模塊里Testclass1中testcase1")
class TestClass2:
    def test_case2(self):
        print('這是pytest_usefixtures包中test_usefixtures模塊里Testclass2中的testcase2')

TestDemo根目錄下的conftest.py

import pytest

@pytest.fixture()  
def login():
    print('登錄操作')
    

TestDemo根目錄下的pytest.ini

[pytest]
usefixtures = login

運(yùn)行整個(gè)項(xiàng)目:

項(xiàng)目中的測(cè)試函數(shù)都調(diào)用了conftest.py中的login。

在這里插入圖片描述

4.使用usefixtures調(diào)用多個(gè)fixture

我們可以使用@pytest.mark.usefixtures('fixturename1','fixturename2')來(lái)調(diào)用多個(gè)fixture。

conftest.py中新增一個(gè)fixture:

import pytest
@pytest.fixture()
def login():
    print('登錄操作')
@pytest.fixture()
def printids():
    print("打印ids。")

修改test_usefixtures.py:

@pytest.mark.usefixtures('login','printids')
class TestClass1:
    def test_case1(self):
        print("這是pytest_usefixtures包中test_usefixtures模塊里Testclass1中testcase1")

運(yùn)行后結(jié)果:

test_case1測(cè)試函數(shù)調(diào)用loginprintids兩個(gè)fixture。

在這里插入圖片描述

2.1.3 autouse——自動(dòng)應(yīng)用

fixture()autouse參數(shù),是fixture自動(dòng)應(yīng)用的標(biāo)識(shí)。

如果autouse=True,則在同作用域下的測(cè)試函數(shù),會(huì)自動(dòng)調(diào)用該fixture;如果autouse=False,則測(cè)試函數(shù)需要主動(dòng)去調(diào)用該fixture。

autouse默認(rèn)是False

示例4:

1.在TestClass1這個(gè)類中定義了一個(gè)login函數(shù),聲明為fixture,并且autouse設(shè)置為True。

TestClass1中的test_case1主動(dòng)調(diào)用了login,但是其他測(cè)試函數(shù)未主動(dòng)調(diào)用。

我們還寫了一個(gè)TestClass2類,類中有一個(gè)test_case4的測(cè)試函數(shù)。

import pytest
class TestClass1:
    @pytest.fixture(autouse=True)  # 啟用自動(dòng)應(yīng)用
    def login(self):
        print("登陸操作")
    def test_case1(self,login):  # 調(diào)用了login這個(gè)fixture函數(shù)
        print("這是Testclass1中testcase1")
    def test_case2(self):  # 沒有調(diào)用
        print('這是Testclass1中testcase2')
    def test_case3(self):  # 沒有調(diào)用
        print('這是Testclass1中testcase3')
class TestClass2:
    def test_case4(self):
        print('這是Testclass2中的testcase4')


運(yùn)行結(jié)果:

通過(guò)運(yùn)行結(jié)果我們可以知道,當(dāng)fixture的autouse=True的時(shí)候,在同作用域內(nèi)的測(cè)試函數(shù)會(huì)自動(dòng)調(diào)用fixture,非同作用域內(nèi)的測(cè)試函數(shù)無(wú)法調(diào)用。

在這里插入圖片描述

2.我們給fixture()帶上更多的參數(shù),修改上面的demo,并設(shè)置fixture的scope=‘class'。

import pytest
@pytest.fixture(scope='class', autouse=True)  # fixture的作用域設(shè)為class級(jí)別,啟用自動(dòng)應(yīng)用
def login():
    print("登陸操作")
class TestClass1:
    def test_case1(self):
        print("這是Testclass1中testcase1")
    def test_case2(self):
        print('這是Testclass1中testcase2')
    def test_case3(self):
        print('這是Testclass1中testcase3')
class TestClass2:
    def test_case4(self):
        print('這是Testclass2中的testcase4')

運(yùn)行結(jié)果:

通過(guò)運(yùn)行結(jié)果我們可以看出,當(dāng)設(shè)置loginscope=‘class'的使用,每一個(gè)測(cè)試類都會(huì)自動(dòng)調(diào)用一次login

autouse的使用也是遵照f(shuō)ixture函數(shù)的設(shè)置來(lái)進(jìn)行的。

在這里插入圖片描述

2.2 fixture使用的靈活性

通過(guò)官方文檔的說(shuō)明,我們知道了pytest的fixture系統(tǒng)是極其的靈活和強(qiáng)大的,官方文檔也為我們以下幾個(gè)靈活使用fixture的例子。

2.2.1 一個(gè)fixture函數(shù)可以調(diào)用其他的fixture

文章前面我們有演示過(guò)一個(gè)fixture函數(shù)調(diào)用其他fixture的例子。

代碼如下:

import pytest
@pytest.fixture()
 def login():
    print("登陸操作")
@pytest.fixture() 
def logout(login): 
    yield
    print("注銷操作")
class TestClass1:
    def test_case1(self,logout):
        print("這是Testclass1中testcase1") 
        

login()實(shí)現(xiàn)了測(cè)試執(zhí)行的前置操作,logout()實(shí)現(xiàn)了測(cè)試執(zhí)行的后置操作。logout()調(diào)用了login,測(cè)試函數(shù)則直接調(diào)用了logout。

fixture在執(zhí)行的時(shí)候是依次執(zhí)行的。假如fixture A 調(diào)用了fixture B,那么執(zhí)行的時(shí)候會(huì)先執(zhí)行fixture B,然后再執(zhí)行fixture A。因?yàn)閒ixture B是fixture A的依賴條件。

所以我們運(yùn)行上面代碼的時(shí)候,是會(huì)先調(diào)用login()然后再調(diào)用logout()的。而logout()中的yield會(huì)讓測(cè)試用例執(zhí)行的時(shí)候先執(zhí)行login中的測(cè)試前置操作,然后再執(zhí)行測(cè)試用例中的內(nèi)容,最后執(zhí)行logoutyield后面測(cè)試后置操作。

這樣的一個(gè)操作,可以將復(fù)雜的測(cè)試需求,變成一個(gè)一個(gè)簡(jiǎn)單而又有組織性的的功能函數(shù),更加方便后期進(jìn)行維護(hù)。

2.2.2 fixture函數(shù)可被反復(fù)重用

兩個(gè)不同的測(cè)試函數(shù)可以調(diào)用同一個(gè)fixture,并且獲得各自的運(yùn)行結(jié)果。測(cè)試函數(shù)之間并不會(huì)因?yàn)檎{(diào)用了同一個(gè)fixture而相互之間產(chǎn)生任何影響。

示例5:

演示代碼:

import pytest
@pytest.fixture()
def first_number():  #fixture函數(shù),返回1
    return 1
@pytest.fixture()
def order(first_number): #fixture函數(shù),調(diào)用了first_number這個(gè)fixture,并且返回一個(gè)list
    return [first_number]
def test_secondnum1(order): #調(diào)用order,并且在order返回的list中添加 2 這個(gè)元素
    order.append(2)
    print(order)
    assert order==[1,2] #斷言
def test_secondnum2(order): #也調(diào)用了order,并在order返回的list中添加 3 這個(gè)元素
    order.append(3)
    print(order)
    assert order==[1,3] #斷言

運(yùn)行結(jié)果:

在這里插入圖片描述

上面這段代碼我們聲明了:
兩個(gè)fixture——first_numberorder。
first_number有一個(gè)返回值: 1
order調(diào)用了first_number,并返回一個(gè)列表: [1] 。

我們還定義了:
兩個(gè)測(cè)試函數(shù)——test_secondnum1test_secondnum2,這兩個(gè)測(cè)試函數(shù)都調(diào)用了order。

test_secondnum1對(duì)order的返回值做了一個(gè)append(2)的操作;test_secondnum1對(duì)order的返回值做了一個(gè)append(3)的操作。

根據(jù)運(yùn)行結(jié)果我們可以看出,兩個(gè)測(cè)試函數(shù)對(duì)調(diào)用的fixture都做出了各自的操作,并且得到各自的一個(gè)運(yùn)行結(jié)果。兩者的運(yùn)行結(jié)果沒有因?yàn)槎颊{(diào)用了order而相互產(chǎn)生影響。

fixture可被反復(fù)重用這一特點(diǎn),對(duì)于確保測(cè)試之間彼此不受影響是非常有用的。我們可以聲明一個(gè)通用的fixture函數(shù),并使用這個(gè)特性來(lái)確保每個(gè)測(cè)試都能得到未受污染的測(cè)試數(shù)據(jù),并且能從一個(gè)干凈的初始狀態(tài)開始執(zhí)行。

2.2.3 測(cè)試函數(shù)/fixture函數(shù)可以一次調(diào)用多個(gè)fixture

文章前面我們有介紹過(guò)如何使用usefixtures來(lái)調(diào)用多個(gè)fixture,由此我們可以知道,pytest是允許測(cè)試函數(shù)和fixture函數(shù)按照自己的需求一次調(diào)用多個(gè)fixture的。

示例6:

演示代碼:

import pytest

@pytest.fixture()
def first_number(): #第一個(gè)fixture,返回1
    return 1

@pytest.fixture()
def second_number(): #第二個(gè)fixture,返回2
    return 2

@pytest.fixture()
def third_number(): #第三個(gè)fixture,返回1
    return 3

@pytest.fixture()
def order(first_number,second_number): #調(diào)用first_number 和 second_number 返回 [1,2]
    return [first_number,second_number]

def test_case(order,third_number):  #調(diào)用order 和 third_number 
    order.append(third_number)     #對(duì) order做append的操作,將third_number的返回值加入list中
    print(order)
    assert order==[1,2,3]  #斷言
    

運(yùn)行結(jié)果:

在這里插入圖片描述

演示代碼中我們聲明了:
四個(gè)fixture——first_numbersecond_number、third_numberorder;
一個(gè)測(cè)試函數(shù)——test_case

order 調(diào)用了first_numbersecond_number;test_case調(diào)用了orderthird_number。他們都根據(jù)自己的需求調(diào)用了多個(gè)fixture,并且正常被執(zhí)行。

2.2.4 同一測(cè)試執(zhí)行期間,fixture可被多次請(qǐng)求

其實(shí)在看官方文檔的時(shí)候,我有點(diǎn)不太理解這部分的內(nèi)容。當(dāng)時(shí)看文字的描述感覺與“fixture能夠被重復(fù)調(diào)用“這一點(diǎn)有沖突,但是通過(guò)官方文檔的代碼示例,我才明白這兩點(diǎn)其實(shí)是不沖突的。

下面我們先看一下官方示例。

示例7:

演示代碼:

import pytest

@pytest.fixture
def first_entry():
    return "a"

@pytest.fixture
def order():
    return []

@pytest.fixture
def append_first(order, first_entry):
    return order.append(first_entry)

def test_string_only(append_first,order, first_entry):
    print(order)
    assert order == [first_entry]

運(yùn)行結(jié)果:

在這里插入圖片描述

示例代碼中聲明了:
三個(gè)fixture函數(shù)——first_entry、orderappend_first;
一個(gè)測(cè)試函數(shù)——test_string_only

first_entry返回了一個(gè)str: "a";
order返回一個(gè)空l(shuí)ist:[]
append_first調(diào)用了first_entryorder,并且返回 order.append(first_entry)

test_string_only調(diào)用了first_entry、orderappend_first,并做了一個(gè)打印order值的操作和斷言操作。

通過(guò)運(yùn)行結(jié)果我們可以看到,test_string_only斷言成功,并且打印的order的值是['a']

如果按照”fixture能夠被重復(fù)調(diào)用“這一特點(diǎn)看,打印的order不應(yīng)該是空l(shuí)ist的嗎?為什么會(huì)是[‘a(chǎn)']呢?

test_string_only在執(zhí)行期間,先執(zhí)行append_first,而append_first調(diào)用了order,并且對(duì)order進(jìn)行了添加元素的操作,更改了order的值,此時(shí)order返回的值會(huì)存在緩存中。當(dāng)test_string_only后面再去”調(diào)用“order的時(shí)候,其實(shí)和append_first引用的是同一個(gè)order對(duì)象,因此測(cè)試斷言才會(huì)成功。

通過(guò)pytest官方文檔我們知道,pytest一次只緩存一個(gè)fixture的實(shí)例,這意味著在使用參數(shù)化fixture時(shí),pytest可以在給定范圍內(nèi)多次調(diào)用一個(gè)fixture。

當(dāng)測(cè)試過(guò)程中先調(diào)用的fixture對(duì)其他fixture有依賴關(guān)系的話,在調(diào)用這個(gè)fixture的時(shí)候它所依賴的fixture也會(huì)被調(diào)用。所以后面測(cè)試執(zhí)行過(guò)程中,如果再次有請(qǐng)求到這些fixture的話,fixture就不會(huì)被再次執(zhí)行,此時(shí)會(huì)直接從緩存中獲取到之前fixture執(zhí)行后返回的數(shù)據(jù)來(lái)使用。

“fixture能夠被重復(fù)調(diào)用“——針對(duì)不同的測(cè)試過(guò)程,目的是為了保障每個(gè)測(cè)試執(zhí)行時(shí)都是一個(gè)干凈的環(huán)境。
“同一測(cè)試執(zhí)行期間,fixture可被多次請(qǐng)求”——同一測(cè)試過(guò)程中,目的是為了保障在測(cè)試過(guò)程中,前后使用的數(shù)據(jù)不會(huì)被重置。

文末說(shuō)明:
以上內(nèi)容是我在閱讀pytest官方文檔后,依照個(gè)人理解進(jìn)行整理。內(nèi)容可能會(huì)有理解錯(cuò)誤之處,歡迎大家留言指正。謝謝

以上就是pytest自動(dòng)化測(cè)試中的fixture的聲明和調(diào)用的詳細(xì)內(nèi)容,更多關(guān)于fixture聲明和調(diào)用的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 使用Plotly Dash進(jìn)行儀表板設(shè)計(jì)的步驟和技巧

    使用Plotly Dash進(jìn)行儀表板設(shè)計(jì)的步驟和技巧

    Plotly Dash 是一個(gè)基于 Python 的開源框架,可以幫助你快速而靈活地構(gòu)建交互式儀表板,本文將介紹使用 Plotly Dash 創(chuàng)建儀表板的步驟和一些技巧,并附上代碼實(shí)例來(lái)演示每個(gè)步驟,需要的朋友可以參考下
    2024-05-05
  • 使用pytorch實(shí)現(xiàn)可視化中間層的結(jié)果

    使用pytorch實(shí)現(xiàn)可視化中間層的結(jié)果

    今天小編就為大家分享一篇使用pytorch實(shí)現(xiàn)可視化中間層的結(jié)果,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-12-12
  • Python之re操作方法(詳解)

    Python之re操作方法(詳解)

    下面小編就為大家?guī)?lái)一篇Python之re操作方法(詳解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-06-06
  • Django如何重置migration的幾種情景

    Django如何重置migration的幾種情景

    這篇文章主要介紹了Django如何重置migration的幾種情景,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2021-02-02
  • python logging 重復(fù)寫日志問(wèn)題解決辦法詳解

    python logging 重復(fù)寫日志問(wèn)題解決辦法詳解

    這篇文章主要介紹了python logging 重復(fù)寫日志問(wèn)題解決辦法詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • 詳解Python實(shí)現(xiàn)進(jìn)度條的4種方式

    詳解Python實(shí)現(xiàn)進(jìn)度條的4種方式

    這篇文章主要介紹了Python實(shí)現(xiàn)進(jìn)度條的4種方式,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01
  • Python實(shí)現(xiàn)npy/mat文件的保存與讀取

    Python實(shí)現(xiàn)npy/mat文件的保存與讀取

    除了常用的csv文件和excel文件之外,我們還可以通過(guò)Python把數(shù)據(jù)保存文npy文件格式和mat文件格式。本文為大家展示了實(shí)現(xiàn)npy文件與mat文件的保存與讀取的示例代碼,需要的可以參考一下
    2022-04-04
  • 在Python中增加和插入元素的示例

    在Python中增加和插入元素的示例

    今天小編就為大家分享一篇在Python中增加和插入元素的示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-11-11
  • 教你如何編寫、保存與運(yùn)行Python程序的方法

    教你如何編寫、保存與運(yùn)行Python程序的方法

    這篇文章主要介紹了教你如何編寫、保存與運(yùn)行Python程序的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • python同時(shí)遍歷數(shù)組的索引和值的實(shí)例

    python同時(shí)遍歷數(shù)組的索引和值的實(shí)例

    今天小編就為大家分享一篇python同時(shí)遍歷數(shù)組的索引和值的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-11-11

最新評(píng)論

昭苏县| 宜春市| 鹰潭市| 乌兰察布市| 色达县| 高安市| 黑龙江省| 屏南县| 淅川县| 江川县| 平邑县| 乃东县| 北安市| 花莲县| 神池县| 东台市| 曲松县| 剑川县| 长阳| 日土县| 韶关市| 宝兴县| 黄石市| 类乌齐县| 宜都市| 翼城县| 泸溪县| 贺兰县| 沛县| 颍上县| 潮安县| 宁海县| 余江县| 蒙山县| 红桥区| 西安市| 玉龙| 雷州市| 普安县| 紫阳县| 囊谦县|