【pytest系列】- parametrize参数化

2024-02-01 17:20

本文主要是介绍【pytest系列】- parametrize参数化,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 🔥 交流讨论:欢迎加入我们一起学习!

🔥 资源分享耗时200+小时精选的「软件测试」资料包

🔥 教程推荐:火遍全网的《软件测试》教程  

📢欢迎点赞 👍 收藏 ⭐留言 📝 如有错误敬请指正!

前面已经提到,pytest和unittest是兼容的,但是它也有不兼容的地方,比如ddt数据驱动,测试夹具fixtures(即setup、teardown)这些功能在pytest中都不能使用了,因为pytest已经不再继承unittest了。

​ 不使用ddt数据驱动那pytest是如何实现参数化的呢?答案就是mark里自带的一个参数化标签。

源码解读

​ 关键代码:@pytest.mark.parametrize

​ 我们先看下源码:def parametrize(self,argnames, argvalues, indirect=False, ids=None, scope=None):,按住ctrl然后点击对应的函数名就可查看源码。

python
<span style="background-color:#282c34"><span style="color:#abb2bf">    <span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">parametrize</span>(<span style="color:#a6e22e">self,argnames, argvalues, indirect=<span style="color:#56b6c2">False</span>, ids=<span style="color:#56b6c2">None</span>, scope=<span style="color:#56b6c2">None</span></span>):</span><span style="color:#98c379">""" Add new invocations to the underlying test function using the listof argvalues for the given argnames.  Parametrization is performedduring the collection phase.  If you need to setup expensive resourcessee about setting indirect to do it rather at test setup time.:arg argnames: a comma-separated string denoting one or more argumentnames, or a list/tuple of argument strings.:arg argvalues: The list of argvalues determines how often atest is invoked with different argument values.  If only oneargname was specified argvalues is a list of values.  If Nargnames were specified, argvalues must be a list of N-tuples,where each tuple-element specifies a value for its respectiveargname.:arg indirect: The list of argnames or boolean. A list of arguments'names (self,subset of argnames). If True the list contains all names fromthe argnames. Each argvalue corresponding to an argname in this list willbe passed as request.param to its respective argname fixturefunction so that it can perform more expensive setups during thesetup phase of a test rather than at collection time.:arg ids: list of string ids, or a callable.If strings, each is corresponding to the argvalues so that they arepart of the test id. If None is given as id of specific test, theautomatically generated id for that argument will be used.If callable, it should take one argument (self,a single argvalue) and returna string or return None. If None, the automatically generated id for thatargument will be used.If no ids are provided they will be generated automatically fromthe argvalues.:arg scope: if specified it denotes the scope of the parameters.The scope is used for grouping tests by parameter instances.It will also override any fixture-function defined scope, allowingto set a dynamic scope using test context or configuration."""</span>
</span></span>

​ 我们来看下主要的四个参数:

​ 🍊参数1-argnames:一个或多个参数名,用逗号分隔的字符串,如"arg1,arg2,arg3",或参数字符串的列表/元组。需要注意的是,参数名需要与用例的入参一致

​ 🍊参数2-argvalues:参数值,必须是列表类型;如果有多个参数,则用元组存放值,一个元组存放一组参数值,元组放在列表。(实际上元组包含列表、列表包含列表也是可以的,可以动手试一下)

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#b18eb1"><em># 只有一个参数username时,列表里都是这个参数的值:</em></span>
<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">"username"</span>, [<span style="color:#3388aa">"user1"</span>, <span style="color:#3388aa">"user2"</span>, <span style="color:#3388aa">"user3"</span>])</span>
<span style="color:#b18eb1"><em># 有多个参数username、pwd,用元组存放参数值,一个元组对应一组参数:</em></span>
<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">"username, pwd"</span>, [(<span style="color:#3388aa">"user1"</span>, <span style="color:#3388aa">"pwd1"</span>), (<span style="color:#3388aa">"user2"</span>, <span style="color:#3388aa">"pwd2"</span>), (<span style="color:#3388aa">"user3"</span>, <span style="color:#3388aa">"pwd3"</span>)])</span></span></span>

​ 🍊参数3-indirect:默认为False,设置为Ture时会把传进来的参数(argnames)当函数执行。后面会进行详解。

​ 🍊参数4-ids:用例的ID,传字符串列表,它可以标识每一个测试用例,自定义测试数据结果显示,增加可读性;需要注意的是ids的长度需要与测试用例的数量一致。

单个参数化

​ 下面我们来看下常用的参数化:

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#f92672">import</span> pytestdata = [(<span style="color:#d19a66">1</span>, <span style="color:#d19a66">2</span>, <span style="color:#d19a66">3</span>), (<span style="color:#d19a66">4</span>, <span style="color:#d19a66">5</span>, <span style="color:#d19a66">9</span>)]<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">'a, b, expect'</span>, data)</span>
<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">test_param</span>(<span style="color:#a6e22e">a, b, expect</span>):</span><span style="color:#e6c07b">print</span>(<span style="color:#98c379">'\n测试数据:{}+{}'</span>.<span style="color:#e6c07b">format</span>(a, b))<span style="color:#f92672">assert</span> a+b == expect</span></span>

​ 运行结果:

shell
<span style="background-color:#282c34"><span style="color:#abb2bf">Testing started at 14:10 ...============================= test session starts =============================
platform win32 -- Python 3.8.1, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- C:\software\python\python.exe
cachedir: .pytest_cache
rootdir: D:\myworkspace\test, inifile: pytest.ini
collecting ... test.py::test_param[1-2-3]
test.py::test_param[4-5-9]
collected 2 itemstest.py::test_param[1-2-3] PASSED                                        [ 50%]
测试数据:1+2test.py::test_param[4-5-9] PASSED                                        [100%]
测试数据:4+5============================== 2 passed in 0.02s ==============================Process finished with exit code 0</span></span>

​ 如上用例参数化后,一条测试数据就会执行一遍用例。

​ 再看下列表包含字典的:

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#f92672">import</span> pytest<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">login</span>(<span style="color:#a6e22e">user, pwd</span>):</span><span style="color:#98c379">"""登录功"""</span><span style="color:#f92672">if</span> user == <span style="color:#98c379">"admin"</span> <span style="color:#f92672">and</span> pwd == <span style="color:#98c379">"admin123"</span>:<span style="color:#f92672">return</span> {<span style="color:#98c379">"code"</span>: <span style="color:#d19a66">0</span>, <span style="color:#98c379">"msg"</span>: <span style="color:#98c379">"登录成功!"</span>}<span style="color:#f92672">else</span>:<span style="color:#f92672">return</span> {<span style="color:#98c379">"code"</span>: <span style="color:#d19a66">1</span>, <span style="color:#98c379">"msg"</span>: <span style="color:#98c379">"登陆失败,账号或密码错误!"</span>}<span style="color:#b18eb1"><em># 测试数据</em></span>
test_datas = [{<span style="color:#98c379">"user"</span>: <span style="color:#98c379">"admin"</span>, <span style="color:#98c379">"pwd"</span>: <span style="color:#98c379">"admin123"</span>, <span style="color:#98c379">"expected"</span>: <span style="color:#98c379">"登录成功!"</span>},{<span style="color:#98c379">"user"</span>: <span style="color:#98c379">""</span>, <span style="color:#98c379">"pwd"</span>: <span style="color:#98c379">"admin123"</span>, <span style="color:#98c379">"expected"</span>: <span style="color:#98c379">"登陆失败,账号或密码错误!"</span>},{<span style="color:#98c379">"user"</span>: <span style="color:#98c379">"admin"</span>, <span style="color:#98c379">"pwd"</span>: <span style="color:#98c379">""</span>, <span style="color:#98c379">"expected"</span>: <span style="color:#98c379">"登陆失败,账号或密码错误!"</span>}]<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">"test_data"</span>, test_datas)</span>
<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">test_login</span>(<span style="color:#a6e22e">test_data</span>):</span><span style="color:#b18eb1"><em># 测试用例</em></span>res = login(test_data[<span style="color:#98c379">"user"</span>], test_data[<span style="color:#98c379">"pwd"</span>])<span style="color:#b18eb1"><em># 断言</em></span><span style="color:#e6c07b">print</span>(<span style="color:#d19a66">111</span>)<span style="color:#f92672">assert</span> res[<span style="color:#98c379">"msg"</span>] == test_data[<span style="color:#98c379">"expected"</span>]</span></span>

​ 运行结果:

shell
<span style="background-color:#282c34"><span style="color:#abb2bf">Testing started at 14:13 ...============================= test session starts =============================
platform win32 -- Python 3.8.1, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- C:\software\python\python.exe
cachedir: .pytest_cache
rootdir: D:\myworkspace\test, inifile: pytest.ini
collecting ... test.py::test_login[test_data0]
test.py::test_login[test_data1]
test.py::test_login[test_data2]
collected 3 itemstest.py::test_login[test_data0] PASSED                                   [ 33%]111test.py::test_login[test_data1] PASSED                                   [ 66%]111test.py::test_login[test_data2] PASSED                                   [100%]111============================== 3 passed in 0.02s ==============================Process finished with exit code 0</span></span>

多个参数化

​ 一个函数或一个类都可以使用多个参数化装饰器,“笛卡尔积”原理。最终生成的用例是n1*n2*n3...条,如下例子,参数一的值有2个,参数二的值有3个,那么最后生成的用例就是2*3条。

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#f92672">import</span> pytestdata1 = [<span style="color:#d19a66">1</span>, <span style="color:#d19a66">2</span>]
data2 = [<span style="color:#98c379">'a'</span>, <span style="color:#98c379">'b'</span>, <span style="color:#98c379">'c'</span>]<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">'test1'</span>, data1)</span>
<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">'test2'</span>, data2)</span>
<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">test_param</span>(<span style="color:#a6e22e">test1, test2</span>):</span><span style="color:#e6c07b">print</span>(<span style="color:#98c379">'\n测试数据:{}-{}'</span>.<span style="color:#e6c07b">format</span>(test1, test2))</span></span>

​ 运行结果:

shell
<span style="background-color:#282c34"><span style="color:#abb2bf">Testing started at 14:15 ...============================= test session starts =============================
platform win32 -- Python 3.8.1, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- C:\software\python\python.exe
cachedir: .pytest_cache
rootdir: D:\myworkspace\test, inifile: pytest.ini
collecting ... test.py::test_param[a-1]
test.py::test_param[a-2]
test.py::test_param[b-1]
test.py::test_param[b-2]
test.py::test_param[c-1]
test.py::test_param[c-2]
collected 6 itemstest.py::test_param[a-1] PASSED                                          [ 16%]
测试数据:1-atest.py::test_param[a-2] PASSED                                          [ 33%]
测试数据:2-atest.py::test_param[b-1] PASSED                                          [ 50%]
测试数据:1-btest.py::test_param[b-2] PASSED                                          [ 66%]
测试数据:2-btest.py::test_param[c-1] PASSED                                          [ 83%]
测试数据:1-ctest.py::test_param[c-2] PASSED                                          [100%]
测试数据:2-c============================== 6 passed in 0.03s ==============================Process finished with exit code 0</span></span>

​ 从上面的例子来看,@pytest.mark.parametrize()其实跟ddt的用法很相似的,多用就好了。

标记数据

​ 在参数化中,也可以标记数据进行断言、跳过等

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#b18eb1"><em># 标记参数化</em></span>
<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">"test_input,expected"</span>, [(<span style="color:#3388aa">"3+5"</span>, <span style="color:#d19a66">8</span>), (<span style="color:#3388aa">"2+4"</span>, <span style="color:#d19a66">6</span>),pytest.param(<span style="color:#3388aa">"6 * 9"</span>, <span style="color:#d19a66">42</span>, marks=pytest.mark.xfail),pytest.param(<span style="color:#3388aa">"6 * 6"</span>, <span style="color:#d19a66">42</span>, marks=pytest.mark.skip)
])</span>
<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">test_mark</span>(<span style="color:#a6e22e">test_input, expected</span>):</span><span style="color:#f92672">assert</span> <span style="color:#e6c07b">eval</span>(test_input) == expected</span></span>

​ 运行结果,可以看到2个通过,1个断言失败的,1个跳过的。

shell
<span style="background-color:#282c34"><span style="color:#abb2bf">Testing started at 14:17 ...============================= test session starts =============================
platform win32 -- Python 3.8.1, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- C:\software\python\python.exe
cachedir: .pytest_cache
rootdir: D:\myworkspace\test, inifile: pytest.ini
collecting ... test.py::test_mark[3+5-8]
test.py::test_mark[2+4-6]
test.py::test_mark[6 * 9-42]
test.py::test_mark[6 * 6-42]
collected 4 itemstest.py::test_mark[3+5-8] 
test.py::test_mark[2+4-6] 
test.py::test_mark[6 * 9-42] 
test.py::test_mark[6 * 6-42] =================== 2 passed, 1 skipped, 1 xfailed in 0.14s ===================Process finished with exit code 0
PASSED                                         [ 25%]PASSED                                         [ 50%]XFAIL                                       [ 75%]
test_input = '6 * 9', expected = 42@pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6),pytest.param("6 * 9", 42, marks=pytest.mark.xfail),pytest.param("6 * 6", 42, marks=pytest.mark.skip)])def test_mark(test_input, expected):
<span style="color:#61aeee">></span>       assert <span style="color:#e6c07b">eval</span>(test_input) == expected
E       AssertionErrortest.py:89: AssertionError
SKIPPED                                     [100%]
Skipped: unconditional skip</span></span>

用例ID

​ 前面源码分析说到ids可以标识每一个测试用例;有多少组数据,就要有多少个id,然后组成一个id的列表;现在来看下实例。

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#f92672">import</span> pytest<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">login</span>(<span style="color:#a6e22e">user, pwd</span>):</span><span style="color:#98c379">"""登录功"""</span><span style="color:#f92672">if</span> user == <span style="color:#98c379">"admin"</span> <span style="color:#f92672">and</span> pwd == <span style="color:#98c379">"admin123"</span>:<span style="color:#f92672">return</span> {<span style="color:#98c379">"code"</span>: <span style="color:#d19a66">0</span>, <span style="color:#98c379">"msg"</span>: <span style="color:#98c379">"登录成功!"</span>}<span style="color:#f92672">else</span>:<span style="color:#f92672">return</span> {<span style="color:#98c379">"code"</span>: <span style="color:#d19a66">1</span>, <span style="color:#98c379">"msg"</span>: <span style="color:#98c379">"登陆失败,账号或密码错误!"</span>}<span style="color:#b18eb1"><em># 测试数据</em></span>
test_datas = [{<span style="color:#98c379">"user"</span>: <span style="color:#98c379">"admin"</span>, <span style="color:#98c379">"pwd"</span>: <span style="color:#98c379">"admin123"</span>, <span style="color:#98c379">"expected"</span>: <span style="color:#98c379">"登录成功!"</span>},{<span style="color:#98c379">"user"</span>: <span style="color:#98c379">""</span>, <span style="color:#98c379">"pwd"</span>: <span style="color:#98c379">"admin123"</span>, <span style="color:#98c379">"expected"</span>: <span style="color:#98c379">"登陆失败,账号或密码错误!"</span>},{<span style="color:#98c379">"user"</span>: <span style="color:#98c379">"admin"</span>, <span style="color:#98c379">"pwd"</span>: <span style="color:#98c379">""</span>, <span style="color:#98c379">"expected"</span>: <span style="color:#98c379">"登陆失败,账号或密码错误!"</span>}]<span style="color:#61aeee">@pytest.mark.parametrize(<span style="color:#3388aa">"test_data"</span>, test_datas, ids=[<span style="color:#3388aa">"输入正确账号、密码,登录成功"</span>,<span style="color:#3388aa">"账号为空,密码正确,登录失败"</span>,<span style="color:#3388aa">"账号正确,密码为空,登录失败"</span>,])</span>
<span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">test_login</span>(<span style="color:#a6e22e">test_data</span>):</span><span style="color:#b18eb1"><em># 测试用例</em></span>res = login(test_data[<span style="color:#98c379">"user"</span>], test_data[<span style="color:#98c379">"pwd"</span>])<span style="color:#b18eb1"><em># 断言</em></span><span style="color:#e6c07b">print</span>(<span style="color:#d19a66">111</span>)<span style="color:#f92672">assert</span> res[<span style="color:#98c379">"msg"</span>] == test_data[<span style="color:#98c379">"expected"</span>]</span></span>

​ 运行结果:

shell
<span style="background-color:#282c34"><span style="color:#abb2bf">Testing started at 10:34 ...============================= test session starts =============================
platform win32 -- Python 3.8.1, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- C:\software\python\python.exe
cachedir: .pytest_cache
rootdir: D:\myworkspace\test, inifile: pytest.ini
collecting ... collected 3 itemstest.py::test_login[\u8f93\u5165\u6b63\u786e\u8d26\u53f7\u3001\u5bc6\u7801\uff0c\u767b\u5f55\u6210\u529f] PASSED [ 33%]111test.py::test_login[\u8d26\u53f7\u4e3a\u7a7a\uff0c\u5bc6\u7801\u6b63\u786e\uff0c\u767b\u5f55\u5931\u8d25] PASSED [ 66%]111test.py::test_login[\u8d26\u53f7\u6b63\u786e\uff0c\u5bc6\u7801\u4e3a\u7a7a\uff0c\u767b\u5f55\u5931\u8d25] PASSED [100%]111============================== 3 passed in 0.02s ==============================Process finished with exit code 0
</span></span>

​ 注意: [\u8f93\u5165\u6b63 ...] 这些并不是乱码,是unicode 编码,因为我们输入的是中文,指定一下编码就可以。在项目的根目录的 conftest.py 文件,加以下代码:

python
<span style="background-color:#282c34"><span style="color:#abb2bf"><span style="color:#61aeee"><span style="color:#f92672">def</span> <span style="color:#61aeee">pytest_collection_modifyitems</span>(<span style="color:#a6e22e">items</span>):</span><span style="color:#98c379">"""测试用例收集完成时,将收集到的item的name和nodeid的中文显示在控制台上:return:"""</span><span style="color:#f92672">for</span> item <span style="color:#f92672">in</span> items:item.name = item.name.encode(<span style="color:#98c379">"utf-8"</span>).decode(<span style="color:#98c379">"unicode_escape"</span>)<span style="color:#e6c07b">print</span>(item.nodeid)item._nodeid = item.nodeid.encode(<span style="color:#98c379">"utf-8"</span>).decode(<span style="color:#98c379">"unicode_escape"</span>)</span></span>

​ 再运行一遍就可以了。

shell
<span style="background-color:#282c34"><span style="color:#abb2bf">Testing started at 10:38 ...============================= test session starts =============================
platform win32 -- Python 3.8.1, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- C:\software\python\python.exe
cachedir: .pytest_cache
rootdir: D:\myworkspace\test, inifile: pytest.ini
collecting ... test.py::test_login[\u8f93\u5165\u6b63\u786e\u8d26\u53f7\u3001\u5bc6\u7801\uff0c\u767b\u5f55\u6210\u529f]
test.py::test_login[\u8d26\u53f7\u4e3a\u7a7a\uff0c\u5bc6\u7801\u6b63\u786e\uff0c\u767b\u5f55\u5931\u8d25]
test.py::test_login[\u8d26\u53f7\u6b63\u786e\uff0c\u5bc6\u7801\u4e3a\u7a7a\uff0c\u767b\u5f55\u5931\u8d25]
collected 3 itemstest.py::test_login[输入正确账号、密码,登录成功] PASSED                 [ 33%]111test.py::test_login[账号为空,密码正确,登录失败] PASSED                 [ 66%]111test.py::test_login[账号正确,密码为空,登录失败] PASSED                 [100%]111============================== 3 passed in 0.02s ==============================Process finished with exit code 0</span></span>

最后我邀请你进入我们的【软件测试学习交流群:785128166】, 大家可以一起探讨交流软件测试,共同学习软件测试技术、面试等软件测试方方面面,还会有免费直播课,收获更多测试技巧,我们一起进阶Python自动化测试/测试开发,走向高薪之路

作为一个软件测试的过来人,我想尽自己最大的努力,帮助每一个伙伴都能顺利找到工作。所以我整理了下面这份资源,现在免费分享给大家,有需要的小伙伴可以关注【公众号:程序员二黑】自提!

 

这篇关于【pytest系列】- parametrize参数化的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/667930

相关文章

详解Spring Boot接收参数的19种方式

《详解SpringBoot接收参数的19种方式》SpringBoot提供了多种注解来接收不同类型的参数,本文给大家介绍SpringBoot接收参数的19种方式,感兴趣的朋友跟随小编一起看看吧... 目录SpringBoot接受参数相关@PathVariable注解@RequestHeader注解@Reque

Java向kettle8.0传递参数的方式总结

《Java向kettle8.0传递参数的方式总结》介绍了如何在Kettle中传递参数到转换和作业中,包括设置全局properties、使用TransMeta和JobMeta的parameterValu... 目录1.传递参数到转换中2.传递参数到作业中总结1.传递参数到转换中1.1. 通过设置Trans的

java如何调用kettle设置变量和参数

《java如何调用kettle设置变量和参数》文章简要介绍了如何在Java中调用Kettle,并重点讨论了变量和参数的区别,以及在Java代码中如何正确设置和使用这些变量,避免覆盖Kettle中已设置... 目录Java调用kettle设置变量和参数java代码中变量会覆盖kettle里面设置的变量总结ja

spring 参数校验Validation示例详解

《spring参数校验Validation示例详解》Spring提供了Validation工具类来实现对客户端传来的请求参数的有效校验,本文给大家介绍spring参数校验Validation示例详... 目录前言一、Validation常见的校验注解二、Validation的简单应用三、分组校验四、自定义校

SpringBoot中Get请求和POST请求接收参数示例详解

《SpringBoot中Get请求和POST请求接收参数示例详解》文章详细介绍了SpringBoot中Get请求和POST请求的参数接收方式,包括方法形参接收参数、实体类接收参数、HttpServle... 目录1、Get请求1.1 方法形参接收参数 这种方式一般适用参数比较少的情况,并且前后端参数名称必须

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

Andrej Karpathy最新采访:认知核心模型10亿参数就够了,AI会打破教育不公的僵局

夕小瑶科技说 原创  作者 | 海野 AI圈子的红人,AI大神Andrej Karpathy,曾是OpenAI联合创始人之一,特斯拉AI总监。上一次的动态是官宣创办一家名为 Eureka Labs 的人工智能+教育公司 ,宣布将长期致力于AI原生教育。 近日,Andrej Karpathy接受了No Priors(投资博客)的采访,与硅谷知名投资人 Sara Guo 和 Elad G

C++11第三弹:lambda表达式 | 新的类功能 | 模板的可变参数

🌈个人主页: 南桥几晴秋 🌈C++专栏: 南桥谈C++ 🌈C语言专栏: C语言学习系列 🌈Linux学习专栏: 南桥谈Linux 🌈数据结构学习专栏: 数据结构杂谈 🌈数据库学习专栏: 南桥谈MySQL 🌈Qt学习专栏: 南桥谈Qt 🌈菜鸡代码练习: 练习随想记录 🌈git学习: 南桥谈Git 🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈�

如何在页面调用utility bar并传递参数至lwc组件

1.在app的utility item中添加lwc组件: 2.调用utility bar api的方式有两种: 方法一,通过lwc调用: import {LightningElement,api ,wire } from 'lwc';import { publish, MessageContext } from 'lightning/messageService';import Ca

科研绘图系列:R语言扩展物种堆积图(Extended Stacked Barplot)

介绍 R语言的扩展物种堆积图是一种数据可视化工具,它不仅展示了物种的堆积结果,还整合了不同样本分组之间的差异性分析结果。这种图形表示方法能够直观地比较不同物种在各个分组中的显著性差异,为研究者提供了一种有效的数据解读方式。 加载R包 knitr::opts_chunk$set(warning = F, message = F)library(tidyverse)library(phyl