Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 打印列表中的项目_Python_Python 3.x_List_Formatting - Fatal编程技术网

Python 打印列表中的项目

Python 打印列表中的项目,python,python-3.x,list,formatting,Python,Python 3.x,List,Formatting,我有一个字典API中的定义列表,希望将其打印为带格式的字符串 我正在寻找的格式示例: 1. having or marked by great volume or bulk : large; also : full 2. numerous 3. filling or capable of filling a large volume or several volumes 这是我正在处理的列表的一个示例: ['having or marked by great volume or bulk :

我有一个字典API中的定义列表,希望将其打印为带格式的字符串

我正在寻找的格式示例:

1. having or marked by great volume or bulk : large; also : full
2. numerous
3. filling or capable of filling a large volume or several volumes
这是我正在处理的列表的一个示例:

['having or marked by great volume or bulk : large; also : full', 'numerous', 'filling or capable of filling a large volume or several volumes']

像这样的东西会起作用,尽管它看起来不像你的照片那么性感:

items=['具有或以大体积或大体积为特征:大;也指满',
"多",,
“填充或能够填充大体积或多体积”]
对于范围内的i(len(items)):
打印(“{}:{}”。格式(i+1,项[i]))
要使用
enumerate()
执行此操作,同时将所有内容放入单个字符串中,您可以执行以下操作:

result=[]
对于枚举中的i、v(项目):
result.append(“{}:{}.”格式(i+1,v))
final=',join(结果)
打印(最终版)
如果您希望打印单个字符串,但每个元素位于不同的行上,您可以使用
join()
如下所示:

final='\n'.加入(结果)

您所说的“打印格式”是什么意思?您希望结果显示在何处?你打算如何运行这个程序?在普通终端窗口中不能有这样的图形输出。好的,我正在使用discord api,我将更改我的问题哦,那么您应该从api文档开始。看起来您正在尝试创建一个Discord嵌入,这将帮助您搜索文档。至于黑体字之类的东西,你只要提供适当的标记文本就可以了,就好像你自己在使用Discord客户端一样。我怎样才能把格式正确的文本放到一个字符串中,而不是一个一个地打印出来呢?使用
枚举
,而不是
范围
,这更像是一种python,我相应地修改了我的答案。
枚举(项,1)
更适合。很好!谢谢@DYZ,你让我回到了文档中。只是学到了一些东西。我很感激。