如何使用python传入不确定个数参数
作者:yaominghui 时间:2023-10-27 22:56:36
这篇文章主要介绍了如何使用python传入不确定个数参数,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Python3自带的一个函数为 zip ,使用方式如下:
In: print zip([1, 2],[3, 4])
Out: [(1, 3), (2, 4)]
In: print zip([1, 2],[3, 4],[5, 6])
Out: [(1, 3, 5), (2, 4, 6)]
但是当我存在一个二维数组:
info = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12],...]
当我不确定 info 的长度的时候,例如 info 的长度可能是 2 也可能是 3 或者更多,那么我怎么将 info 所有的参数传入 zip 呢?
这里涉及到 按位置传递 参数的方法,所以解决的办法为:
zip(*info)
来源:https://www.cnblogs.com/TTyb/p/6439209.html
标签:python,传入,参数
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
几个MySQL高频面试题的解答
2024-01-19 05:13:49
![](https://img.aspxhome.com/file/2023/3/129873_0s.png)
pycharm无法导入lxml的解决办法
2023-08-24 04:34:39
![](https://img.aspxhome.com/file/2023/2/87922_0s.png)
vue实现一个单独的组件注释
2024-04-27 15:47:04
![](https://img.aspxhome.com/file/2023/6/133156_0s.jpg)
javascript延时重复执行函数 lLoopRun.js
2024-04-22 13:22:57
利用Python实现自动工作汇报的脚本分享
2022-05-31 10:55:37
![](https://img.aspxhome.com/file/2023/8/128498_0s.png)
Python终端输出彩色字符方法详解
2023-11-18 22:04:17
![](https://img.aspxhome.com/file/2023/4/88874_0s.png)
150行Python代码实现带界面的数独游戏
2023-08-30 13:03:47
![](https://img.aspxhome.com/file/2023/0/112130_0s.png)
使用Python导出Excel图表以及导出为图片的方法
2021-02-28 09:59:21
![](https://img.aspxhome.com/file/2023/1/80601_0s.png)
request基本使用及各种请求方式参数的示例
2021-03-31 02:32:52
Go语言中的UTF-8实现
2024-04-25 15:30:51
简介Python的collections模块中defaultdict类型的用法
2021-01-04 20:14:54
asp检测服务器XmlHttp组件支持情况
2008-03-03 12:30:00
python celery分布式任务队列的使用详解
2021-04-22 18:17:56
![](https://img.aspxhome.com/file/2023/1/97641_0s.png)
MySQL中使用FREDATED引擎实现跨数据库服务器、跨实例访问
2024-01-25 12:55:52
![](https://img.aspxhome.com/file/2023/3/74853_0s.png)
MySQL数据库事务隔离级别介绍(Transaction Isolation Level)
2024-01-18 05:54:11
![](https://img.aspxhome.com/file/2023/0/116760_0s.jpg)
Django模板报TemplateDoesNotExist异常(亲测可行)
2023-11-02 18:53:49
![](https://img.aspxhome.com/file/2023/2/99312_0s.png)
Apache DophinScheduler定时调度Python脚本的实现
2021-06-23 15:02:54
![](https://img.aspxhome.com/file/2023/0/93780_0s.png)
javascript 动态插入技术
2009-12-14 20:50:00
python之 matplotlib和pandas绘图教程
2021-07-16 01:50:11
![](https://img.aspxhome.com/file/2023/5/133775_0s.jpg)
js刷新页面方法大全
2023-08-06 21:05:34