社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

在python中同时创建多个矫揉造作的函数

pythonstudent27 • 4 年前 • 1806 次点击  

我是python新手,目前正在学校完成一个项目。 如果我要写一个名为 inputfunction() 其工作原理如下:

var1, coordinates = inputfunction()
"enter var1": 0
"enter coordinates" (x,y): 0,1
>>> print(var1)
0
>>> print(coordinates)
[0, 1]

我真的不知道从哪里开始。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/130180
文章 [ 1 ]  |  最新文章 4 年前
Samwise
Reply   •   1 楼
Samwise    4 年前

将两个不同的值作为元组返回。

>>> def inputfunction() -> tuple[int, list[int]]:
...     return (
...         int(input('"enter var1": ')),
...         [int(n) for n in input('"enter coordinates" (x,y): ').split(",")]
...     )
...
>>> var1, coordinates = inputfunction()
"enter var1": 0
"enter coordinates" (x,y): 0,1
>>> print(var1)
0
>>> print(coordinates)
[0, 1]