社区所有版块导航
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中,如何水平而不是垂直地执行此操作?

Ben • 5 年前 • 1451 次点击  

我在def函数中有这段代码,所以我只显示希望水平设置而不是垂直设置的代码。有人知道怎么做吗?我也希望没有括号。

values=random.randint(1,6), random.randint(1,6), random.randint(1,6), random.randint(1,6), random.randint(1,6)
   print("\nYou rerolled some dice and the new values are:")
   print("Die 1:", values[0]) 
   print("Die 2:", values[1]) 
   print("Die 3:", values[2]) 
   print("Die 4:", values[3]) 
   print("Die 5:", values[4])
   return values

输出:

You rerolled some dice and the new values are:
Die 1: 2
Die 2: 1
Die 3: 2
Die 4: 5
Die 5: 6

我希望它看起来怎么样

You rolled some dice and the new values are: 2, 1, 2, 5, 6
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50512
 
1451 次点击  
文章 [ 6 ]  |  最新文章 5 年前