

注意:钉钉手机端显示markdown格式的文本有问题,兼容性问题。 https://developer.aliyun.com/ask/601015
示例效果:




二维列表转markdown格式
# 使用提醒:
# 1. xbot包提供软件自动化、数据表格、Excel、日志、AI等功能
# 2. package包提供访问当前应用数据的功能,如获取元素、访问全局变量、获取资源文件等功能
# 3. 当此模块作为流程独立运行时执行main函数
# 4. 可视化流程中可以通过"调用模块"的指令使用此模块
import xbot
from xbot import print, sleep
from .import package
from .package import variables as glv
def list_to_markdown(table):
# Calculate the maximum length of each column
max_lens = [max(len(str(item)) for item in col) for col in zip(*table)]
# Create the header row
header = ' | '.join(f"{str(item).ljust(max_lens[i])}" for i, item in enumerate(table[0]))
separator = ' | '.join('-' * max_lens[i] for i in range(len(max_lens)))
# Create the data rows
rows = []
for row in table[1:]:
rows.append(' | '.join(f"{str(item).ljust(max_lens[i])}" for i, item in enumerate(row)))
# Combine header, separator, and rows
markdown_table = f"{header}\n{separator}\n" + "\n".join(rows)
return markdown_table
def main(args):
pass

