自动生成测试用例_接口测试用例自动生成工具

前言

写用例之前,我们应该熟悉API的详细信息。建议使用抓包工具Charles或AnyProxy进行抓包。

har2case

我们先来了解一下另一个项目har2case 他的工作原理就是将当前主流的抓包工具和浏览器都支持将抓取得到的数据包导出为标准通用的 HAR 格式(HTTP Archive),然后 HttpRunner 将 HAR 格式的数据包转换为YAML/JSON格式的测试用例文件。 这里使用charles抓取百度首页进行演示

选中百度请求,右键点击Export Session,导出到/hrun_demo/har下,命名为baidu,格式选择HTTP Archive(.har),点击save

此时,har文件夹下会多出baidu.har文件

har2case生成用例

可以使用命令har2case将Har文件转成测试用例,先使用命令har2case -h查看帮助文档

(httprunner_env) ➜  har har2case -h       
usage: har2case har2case [-h] [-2y] [-2j] [--filter FILTER][--exclude EXCLUDE][har_source_file]positional arguments:har_source_file       Specify HAR source fileoptional arguments:-h, --help            show this help message and exit-2y, --to-yml, --to-yamlConvert to YAML format, if not specified, convert topytest format by default.-2j, --to-json        Convert to JSON format, if not specified, convert topytest format by default.--filter FILTER       Specify filter keyword, only url include filter stringwill be converted.--exclude EXCLUDE     Specify exclude keyword, url that includes excludestring will be ignored, multiple keywords can bejoined with '|'
  • -2y:转换为yaml格式,如果没有指定,默认转换为pytest格式
  • -2j:转换为json格式,如果没有指定,默认转换为pytest格式
  • –filter:指定筛选关键字,仅url包含筛选字符串将被转换。
  • –exclude:指定exclude关键字,包括exclude的url字符串将被忽略,可以选择多个关键字以“|”联接

生成pytest格式的用例

HttpRunner 3.0.7版本开始,har2case将HAR文件默认转换成pytest,强烈建议pytest格式而不是以前的YAML / JSON格式编写和维护测试用例。 这里也是博主从pytest框架转换为httprunner框架的原因之一 运行命令将har文件转换成测试用例:

(httprunner_env) ➜  har har2case baidu.har
2021-02-05 11:27:32.945 | INFO     | httprunner.ext.har2case.core:gen_testcase:356 - Start to generate testcase from /Users/jkc/hrun/hrun_demo/har/baidu.har
2021-02-05 11:27:32.945 | INFO     | httprunner.ext.har2case.core:_make_testcase:347 - Extract info from HAR file and prepare for testcase.
2021-02-05 11:27:32.948 | INFO     | httprunner.compat:ensure_testcase_v3:219 - ensure compatibility with testcase format v2
2021-02-05 11:27:32.948 | INFO     | httprunner.loader:load_dot_env_file:127 - Loading environment variables from /Users/jkc/hrun/hrun_demo/.env
2021-02-05 11:27:32.949 | DEBUG    | httprunner.utils:set_os_environ:33 - Set OS environment variable: USERNAME
2021-02-05 11:27:32.949 | DEBUG    | httprunner.utils:set_os_environ:33 - Set OS environment variable: PASSWORD
2021-02-05 11:27:32.950 | INFO     | httprunner.make:make_testcase:349 - start to make testcase: /Users/jkc/hrun/hrun_demo/har/baidu.har
2021-02-05 11:27:32.951 | INFO     | httprunner.make:make_testcase:442 - generated testcase: /Users/jkc/hrun/hrun_demo/har/baidu_test.py
2021-02-05 11:27:32.952 | INFO     | httprunner.make:format_pytest_with_black:170 - format pytest cases with black ...
reformatted /Users/songyingkai/hrun/hrun_demo/har/baidu_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2021-02-05 11:27:33.181 | INFO     | httprunner.ext.har2case.core:gen_testcase:377 - generated testcase: /Users/jkc/hrun/hrun_demo/har/baidu_test.py
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

生成的pytest文件是标准的python文件,如下所示:

# NOTE: Generated By HttpRunner v3.1.4
# FROM: har/baidu.harfrom httprunner import HttpRunner, Config, Step, RunRequest, RunTestCaseclass TestCaseBaidu(HttpRunner):config = Config("testcase description").verify(False)teststeps = [Step(RunRequest("/").get("https://www.baidu.com/").with_headers(**{"Host": "www.baidu.com","Connection": "keep-alive","Cache-Control": "max-age=0","sec-ch-ua": '"Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"',"sec-ch-ua-mobile": "?0","Upgrade-Insecure-Requests": "1","User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9","Sec-Fetch-Site": "none","Sec-Fetch-Mode": "navigate","Sec-Fetch-User": "?1","Sec-Fetch-Dest": "document","Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7","Cookie": "PSTM=1610459846; BAIDUID=A40AD6AD806FBBED1033903732FFA453:FG=1; BD_UPN=123253; BIDUPSID=898B917A8EF92E036B0F06DC792638A1; __yjs_duid=1_c391922164c20246fd49e4ad821d46c41610613507042; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=33423_33513_33403_33273_33594_33585_26350_33568; delPer=0; BD_CK_SAM=1; PSINO=5; BAIDUID_BFESS=A40AD6AD806FBBED1033903732FFA453:FG=1; COOKIE_SESSION=86630_1_9_6_41_5_0_0_8_2_1_0_0_0_71_0_1612340974_1611912344_1612427533%7C9%23262013_235_1611912339%7C9; BD_HOME=1; ZD_ENTRY=baidu; BA_HECTOR=20ag2180aga18k21mm1g1pegu0r",}).with_cookies(**{"PSTM": "1610459846","BAIDUID": "A40AD6AD806FBBED1033903732FFA453:FG=1","BD_UPN": "123253","BIDUPSID": "898B917A8EF92E036B0F06DC792638A1","__yjs_duid": "1_c391922164c20246fd49e4ad821d46c41610613507042","BDORZ": "B490B5EBF6F3CD402E515D22BCDA1598","H_PS_PSSID": "33423_33513_33403_33273_33594_33585_26350_33568","delPer": "0","BD_CK_SAM": "1","PSINO": "5","BAIDUID_BFESS": "A40AD6AD806FBBED1033903732FFA453:FG=1","COOKIE_SESSION": "86630_1_9_6_41_5_0_0_8_2_1_0_0_0_71_0_1612340974_1611912344_1612427533%7C9%23262013_235_1611912339%7C9","BD_HOME": "1","ZD_ENTRY": "baidu","BA_HECTOR": "20ag2180aga18k21mm1g1pegu0r",}).validate().assert_equal("status_code", 200).assert_equal('headers."Content-Type"', "text/html;charset=utf-8")),]if __name__ == "__main__":TestCaseBaidu().test_start()

可以使用命令hrunpytest运行,实际上,hrun是pytest的封装,效果基本相同。

(httprunner_env) ➜  har hrun baidu_test.py 
2021-02-05 14:03:39.279 | INFO     | httprunner.make:__make:512 - make path: /Users/jkc/hrun/hrun_demo/har/baidu_test.py
2021-02-05 14:03:39.279 | INFO     | httprunner.make:format_pytest_with_black:170 - format pytest cases with black ...
No Path provided. Nothing to do 😴
2021-02-05 14:03:39.457 | INFO     | httprunner.cli:main_run:56 - start to run tests with pytest. HttpRunner version: 3.1.4
============================================= test session starts =============================================
platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1
rootdir: /Users/songyingkai/hrun/hrun_demo/har
plugins: metadata-1.11.0, html-2.1.1
collected 1 item                                                                                              baidu_test.py .                                                                                         [100%]============================================== 1 passed in 0.25s ==============================================
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

(httprunner_env) ➜  har pytest baidu_test.py 
============================================= test session starts =============================================
platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1
rootdir: /Users/songyingkai/hrun/hrun_demo/har
plugins: metadata-1.11.0, html-2.1.1
collected 1 item                                                                                              baidu_test.py .                                                                                         [100%]============================================== warnings summary ===============================================
baidu_test.py::TestCaseBaidu::test_start/Users/songyingkai/.virtualenvs/httprunner_env/lib/python3.7/site-packages/urllib3/connectionpool.py:1020: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.baidu.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warningsInsecureRequestWarning,-- Docs: https://docs.pytest.org/en/latest/warnings.html
======================================== 1 passed, 1 warning in 0.47s =========================================

生成测试用例(YAML/JSON)

当然,你也可以生成YAML/JSON测试用例。 只需要在har2case命令后 添加-2y/--to-yml-2j/--to-json

生成YAML格式:

har har2case baidu.har -2y

(httprunner_env) ➜  har har2case baidu.har -2y
2021-02-05 14:23:48.484 | INFO     | httprunner.ext.har2case.core:gen_testcase:356 - Start to generate testcase from /Users/jkc/hrun/hrun_demo/har/baidu.har
2021-02-05 14:23:48.484 | INFO     | httprunner.ext.har2case.core:_make_testcase:347 - Extract info from HAR file and prepare for testcase.
2021-02-05 14:23:48.488 | INFO     | httprunner.ext.har2case.utils:dump_yaml:108 - dump testcase to YAML format.
2021-02-05 14:23:48.492 | INFO     | httprunner.ext.har2case.utils:dump_yaml:115 - Generate YAML testcase successfully: /Users/jkc/hrun/hrun_demo/har/baidu.yml
2021-02-05 14:23:48.493 | INFO     | httprunner.ext.har2case.core:gen_testcase:377 - generated testcase: /Users/jkc/hrun/hrun_demo/har/baidu.yml
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

查看生成的yaml文件

config:name: testcase descriptionvariables: {}verify: false
teststeps:
-   name: /request:cookies:BAIDUID: A40AD6AD806FBBED1033903732FFA453:FG=1BAIDUID_BFESS: A40AD6AD806FBBED1033903732FFA453:FG=1BA_HECTOR: 20ag2180aga18k21mm1g1pegu0rBDORZ: B490B5EBF6F3CD402E515D22BCDA1598BD_CK_SAM: '1'BD_HOME: '1'BD_UPN: '123253'BIDUPSID: 898B917A8EF92E036B0F06DC792638A1COOKIE_SESSION: 86630_1_9_6_41_5_0_0_8_2_1_0_0_0_71_0_1612340974_1611912344_1612427533%7C9%23262013_235_1611912339%7C9H_PS_PSSID: '33423_33513_33403_33273_33594_33585_26350_33568'PSINO: '5'PSTM: '1610459846'ZD_ENTRY: baidu__yjs_duid: 1_c391922164c20246fd49e4ad821d46c41610613507042delPer: '0'headers:Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Accept-Encoding: gzip, deflate, brAccept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7Cache-Control: max-age=0Connection: keep-aliveCookie: PSTM=1610459846; BAIDUID=A40AD6AD806FBBED1033903732FFA453:FG=1;BD_UPN=123253; BIDUPSID=898B917A8EF92E036B0F06DC792638A1; __yjs_duid=1_c391922164c20246fd49e4ad821d46c41610613507042;BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=33423_33513_33403_33273_33594_33585_26350_33568;delPer=0; BD_CK_SAM=1; PSINO=5; BAIDUID_BFESS=A40AD6AD806FBBED1033903732FFA453:FG=1;COOKIE_SESSION=86630_1_9_6_41_5_0_0_8_2_1_0_0_0_71_0_1612340974_1611912344_1612427533%7C9%23262013_235_1611912339%7C9;BD_HOME=1; ZD_ENTRY=baidu; BA_HECTOR=20ag2180aga18k21mm1g1pegu0rHost: www.baidu.comSec-Fetch-Dest: documentSec-Fetch-Mode: navigateSec-Fetch-Site: noneSec-Fetch-User: ?1Upgrade-Insecure-Requests: '1'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36(KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36sec-ch-ua: '"Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"'sec-ch-ua-mobile: ?0method: GETurl: https://www.baidu.com/validate:-   eq:- status_code- 200-   eq:- headers.Content-Type- text/html;charset=utf-8

生成JSON格式:

har2case baidu.har -2j
(httprunner_env) ➜  har har2case baidu.har -2j
2021-02-05 14:25:35.729 | INFO     | httprunner.ext.har2case.core:gen_testcase:356 - Start to generate testcase from /Users/jkc/hrun/hrun_demo/har/baidu.har
2021-02-05 14:25:35.730 | INFO     | httprunner.ext.har2case.core:_make_testcase:347 - Extract info from HAR file and prepare for testcase.
2021-02-05 14:25:35.732 | INFO     | httprunner.ext.har2case.utils:dump_json:121 - dump testcase to JSON format.
2021-02-05 14:25:35.733 | INFO     | httprunner.ext.har2case.utils:dump_json:130 - Generate JSON testcase successfully: /Users/jkc/hrun/hrun_demo/har/baidu.json
2021-02-05 14:25:35.733 | INFO     | httprunner.ext.har2case.core:gen_testcase:377 - generated testcase: /Users/jkc/hrun/hrun_demo/har/baidu.json
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

查看生成的json格式

{"config": {"name": "testcase description","variables": {},"verify": false},"teststeps": [{"name": "/","request": {"url": "https://www.baidu.com/","method": "GET","cookies": {"PSTM": "1610459846","BAIDUID": "A40AD6AD806FBBED1033903732FFA453:FG=1","BD_UPN": "123253","BIDUPSID": "898B917A8EF92E036B0F06DC792638A1","__yjs_duid": "1_c391922164c20246fd49e4ad821d46c41610613507042","BDORZ": "B490B5EBF6F3CD402E515D22BCDA1598","H_PS_PSSID": "33423_33513_33403_33273_33594_33585_26350_33568","delPer": "0","BD_CK_SAM": "1","PSINO": "5","BAIDUID_BFESS": "A40AD6AD806FBBED1033903732FFA453:FG=1","COOKIE_SESSION": "86630_1_9_6_41_5_0_0_8_2_1_0_0_0_71_0_1612340974_1611912344_1612427533%7C9%23262013_235_1611912339%7C9","BD_HOME": "1","ZD_ENTRY": "baidu","BA_HECTOR": "20ag2180aga18k21mm1g1pegu0r"},"headers": {"Host": "www.baidu.com","Connection": "keep-alive","Cache-Control": "max-age=0","sec-ch-ua": "\"Chromium\";v=\"88\", \"Google Chrome\";v=\"88\", \";Not A Brand\";v=\"99\"","sec-ch-ua-mobile": "?0","Upgrade-Insecure-Requests": "1","User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36","Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9","Sec-Fetch-Site": "none","Sec-Fetch-Mode": "navigate","Sec-Fetch-User": "?1","Sec-Fetch-Dest": "document","Accept-Encoding": "gzip, deflate, br","Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7","Cookie": "PSTM=1610459846; BAIDUID=A40AD6AD806FBBED1033903732FFA453:FG=1; BD_UPN=123253; BIDUPSID=898B917A8EF92E036B0F06DC792638A1; __yjs_duid=1_c391922164c20246fd49e4ad821d46c41610613507042; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; H_PS_PSSID=33423_33513_33403_33273_33594_33585_26350_33568; delPer=0; BD_CK_SAM=1; PSINO=5; BAIDUID_BFESS=A40AD6AD806FBBED1033903732FFA453:FG=1; COOKIE_SESSION=86630_1_9_6_41_5_0_0_8_2_1_0_0_0_71_0_1612340974_1611912344_1612427533%7C9%23262013_235_1611912339%7C9; BD_HOME=1; ZD_ENTRY=baidu; BA_HECTOR=20ag2180aga18k21mm1g1pegu0r"}},"validate": [{"eq": ["status_code",200]},{"eq": ["headers.Content-Type","text/html;charset=utf-8"]}]}]
}

 YAML/JSON用例和pytest用例文件含有相同的信息,也可以使用hrun运行。

(httprunner_env) ➜  har hrun baidu.yml    
2021-02-05 14:28:05.573 | INFO     | httprunner.make:__make:512 - make path: /Users/jkc/hrun/hrun_demo/har/baidu.yml
2021-02-05 14:28:05.582 | INFO     | httprunner.compat:ensure_testcase_v3:219 - ensure compatibility with testcase format v2
2021-02-05 14:28:05.582 | INFO     | httprunner.loader:load_dot_env_file:127 - Loading environment variables from /Users/jkc/hrun/hrun_demo/.env
2021-02-05 14:28:05.582 | DEBUG    | httprunner.utils:set_os_environ:33 - Set OS environment variable: USERNAME
2021-02-05 14:28:05.582 | DEBUG    | httprunner.utils:set_os_environ:33 - Set OS environment variable: PASSWORD
2021-02-05 14:28:05.583 | INFO     | httprunner.make:make_testcase:349 - start to make testcase: /Users/jkc/hrun/hrun_demo/har/baidu.yml
2021-02-05 14:28:05.583 | INFO     | httprunner.make:make_testcase:442 - generated testcase: /Users/jkc/hrun/hrun_demo/har/baidu_test.py
2021-02-05 14:28:05.584 | INFO     | httprunner.make:format_pytest_with_black:170 - format pytest cases with black ...
reformatted /Users/songyingkai/hrun/hrun_demo/har/baidu_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2021-02-05 14:28:05.769 | INFO     | httprunner.cli:main_run:56 - start to run tests with pytest. HttpRunner version: 3.1.4
============================================= test session starts =============================================
platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1
rootdir: /Users/songyingkai/hrun/hrun_demo/har
plugins: metadata-1.11.0, html-2.1.1
collected 1 item                                                                                              baidu_test.py .                                                                                         [100%]============================================== 1 passed in 0.26s ==============================================
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit
(httprunner_env) ➜  har hrun baidu.json 
2021-02-05 14:28:25.793 | INFO     | httprunner.make:__make:512 - make path: /Users/jkc/hrun/hrun_demo/har/baidu.json
2021-02-05 14:28:25.794 | INFO     | httprunner.compat:ensure_testcase_v3:219 - ensure compatibility with testcase format v2
2021-02-05 14:28:25.794 | INFO     | httprunner.loader:load_dot_env_file:127 - Loading environment variables from /Users/jkc/hrun/hrun_demo/.env
2021-02-05 14:28:25.794 | DEBUG    | httprunner.utils:set_os_environ:33 - Set OS environment variable: USERNAME
2021-02-05 14:28:25.794 | DEBUG    | httprunner.utils:set_os_environ:33 - Set OS environment variable: PASSWORD
2021-02-05 14:28:25.795 | INFO     | httprunner.make:make_testcase:349 - start to make testcase: /Users/jkc/hrun/hrun_demo/har/baidu.json
2021-02-05 14:28:25.795 | INFO     | httprunner.make:make_testcase:442 - generated testcase: /Users/jkc/hrun/hrun_demo/har/baidu_test.py
2021-02-05 14:28:25.795 | INFO     | httprunner.make:format_pytest_with_black:170 - format pytest cases with black ...
reformatted /Users/songyingkai/hrun/hrun_demo/har/baidu_test.py
All done! ✨ 🍰 ✨
1 file reformatted.
2021-02-05 14:28:25.975 | INFO     | httprunner.cli:main_run:56 - start to run tests with pytest. HttpRunner version: 3.1.4
============================================= test session starts =============================================
platform darwin -- Python 3.7.6, pytest-5.4.3, py-1.10.0, pluggy-0.13.1
rootdir: /Users/songyingkai/hrun/hrun_demo/har
plugins: metadata-1.11.0, html-2.1.1
collected 1 item                                                                                              baidu_test.py .                                                                                         [100%]============================================== 1 passed in 0.31s ==============================================
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit

最后感谢每一个认真阅读我文章的人,礼尚往来总是要有的,这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你! 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/681373.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【AI】安装ubuntu20.04教程(未完待续)

目录 1 制作ubuntu20.04系统盘1.1 下载ubuntu镜像1.2 使用ultraiso写入镜像 2 安装Ubuntu系统 1 制作ubuntu20.04系统盘 1.1 下载ubuntu镜像 在清华镜像站https://mirrors.tuna.tsinghua.edu.cn/下载ubuntu20.04镜像 路径为/ubuntu-releases/20.04/,下载ubuntu-20…

操作系统(16)----磁盘相关

目录 一.磁盘相关概念 1.磁盘 2.磁道 3.扇区 4.盘面、柱面 5.磁盘的分类 二.磁盘调度算法 1.一次磁盘读/写操作需要的时间 2.先来先服务算法(FCFS) 3.最短寻找时间优先(SSTF) 4.扫描算法(SCAN) 5.LOOK调度算法 6.循环扫描算法(C-SCAN) 7.C-LOOK调度算法 三.减少…

9.【CPP】List (迭代器的模拟实现||list迭代器失效||list的模拟实现)

介绍 list是可以在常数范围内在任意位置进行插入和删除的序列式容器,并且该容器可以前后双向迭代。list的底层是双向链表结构,双向链表中每个元素存储在互不相关的独立节点中,在节点中通过指针指向其前一个元素和后一个元素。list与forward_…

华为机考入门python3--(12)牛客12-字符串反转

分类:字符串 知识点: 字符串是否为空 if not my_str 字符串逆序 my_str[::-1] 题目来自【牛客】 def reverse_string(s): # 判断字符串是否为空或只包含空格 if not s.strip(): return "" # 使用Python的切片语法反转字符串 re…

Pytorch的可视化

1 使用 wandb进行可视化训练过程 本文章将从wandb的安装、wandb的使用、demo的演示进行讲解。 1.1 如何安装wandb? wandb的安装比较简单,在终端中执行如下的命令即可: pip install wandb在安装完成之后,我们需要,去…

matlab入门,在线编辑,无需安装matab

matlab相关教程做的很完善,除了B站看看教程,官方教程我觉得更加高效。跟着教程一步一步编辑,非常方便。 阅读 MATLAB 官方教程: MATLAB 官方教程提供了从基础到高级的教学内容,内容包括 MATLAB 的基本语法、数据处理…

Vue3高频知识点和写法

一 Vue插件 二 vue3项目创建 创建完成后npm install npm run dev 三 setup 一 响应式数据 setup函数是用来代替data和methods的写法的,在setup函数中声明的数据和函数,导出后可以在页面中使用。 但是暂时不是响应式数据,如果要响应式数据的…

C++笔记1:操纵符输入输出

C操纵符用来控制输出控制,一是输出的形式,二是控制补白的数量和位置。本文记录一下,在一些笔试的ACM模式可能有用。其中1-4节的部分是关于格式化输入输出操作,5-6节的部分是关于未格式化输入输出操作。 1. 控制布尔值的格式 一般…

C语言—基础数据类型(含进制转换)

进制转换不多,但我觉得适合小白(我爱夸自己嘿嘿) 练习 1. 确认基础类型所占用的内存空间(提示:使用sizeof 运算符): 在这里我说一下,long 类型通常占用 4 字节。在 64 位系统上,long 类型通常也可为 8 字节。 格式…

LeetCode、208. 实现 Trie (前缀树)【中等,自定义数据结构】

文章目录 前言LeetCode、208. 实现 Trie (前缀树)【中等,自定义数据结构】题目链接与分类思路 资料获取 前言 博主介绍:✌目前全网粉丝2W,csdn博客专家、Java领域优质创作者,博客之星、阿里云平台优质作者、专注于Java后端技术领…

低资源学习与知识图谱:构建与应用

目录 前言1 低资源学习方法1.1 数据增强1.2 特征增强1.3 模型增强 2 低资源知识图谱构建与推理2.1 元关系学习2.2 对抗学习2.3 零样本关系抽取2.4 零样本学习与迁移学习2.5 零样本学习与辅助信息 3 基于知识图谱的低资源学习应用3.1 零样本图像分类3.2 知识增强的零样本学习3.3…

云原生介绍与容器的基本概念

云原生介绍 1、云原生的定义 云原生为用户指定了一条低心智负担的、敏捷的、能够以可扩展、可复制的方式最大化地利用云的能力、发挥云的价值的最佳路径。 2、云原生思想两个理论 第一个理论基础是:不可变基础设施。 第二个理论基础是:云应用编排理…

备战蓝桥杯---图论基础理论

图的存储&#xff1a; 1.邻接矩阵&#xff1a; 我们用map[i][j]表示i--->j的边权 2.用vector数组&#xff08;在搜索专题的游戏一题中应用过&#xff09; 3.用邻接表&#xff1a; 下面是用链表实现的基本功能的代码&#xff1a; #include<bits/stdc.h> using nam…

纪念一下 开始写博客两周以来第一次入围榜单

两周里 创作博客 第一次进入热榜 虽然只有几十名 但也算是一个突破 确实没想到自己随便做的笔记就入围了 感谢各位大佬的支持&#xff01;继续进步&#xff01;&#x1f973;&#x1f973;&#x1f973;

服务流控(Sentinel)

引入依赖 <!-- 必须的 --> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId> </dependency><!-- sentinel 核心库 --> <dependency><groupId>com.ali…

权限系统设计

权限系统设计 RBAC 基于角色的访问控制 ABAC 基于属性的访问控制 普通的系统无非 CRUD&#xff0c;那系统如何控制一个用户该看到哪些数据、能操作哪些功能&#xff1f;日常开发中最常用到 RBAC 和 OAuth2 这两种访问控制和授权方案 RBAC 基于角色的访问控制 所有的访问控制模…

力扣精选算法100道——【模板】前缀和 (二维)

目录 &#x1f388;题目解析 &#x1f388;算法原理 &#x1f388;实现代码 二维前缀和【模板】 &#x1f388;题目解析 上一题我们讲述了一维的前缀和求法。 第一行三个参数&#xff0c;n是行数3&#xff0c;m是列数4&#xff0c;q3代表查询次数 接下来就是n行m列的矩阵…

基于python混沌系统敏感文本信息加密算法的研究与实现,附源码

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝30W、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取源码联系&#x1f345; &#x1f447;&#x1f3fb; 精彩专栏推荐订阅&#x1f447;…

微服务OAuth 2.1认证授权Demo方案(Spring Security 6)

文章目录 一、介绍二、auth微服务代码1. SecurityConfig2. UserDetailsService3. 总结 三、gateway微服务代码1. 统一处理CORS问题 四、content微服务代码1. controller2. SecurityConfig3. 解析JWT Utils4. 总结 五、一些坑 书接上文 微服务OAuth 2.1认证授权可行性方案(Sprin…

【51单片机】串口(江科大)

8.1串口通信 1.串口介绍 2.硬件电路 3.电平标准 电平标准是数据1和数据0的表达方式,是传输线缆中人为规定的电压与数据的对应关系,串口常用的电平标准有如下三种: 电平标准是数据1和数据O的表达方式,是传输线缆中人为规定的电 压与数据的对应关系,串口常用的电平标准有如下…