You can use tabulate to convert dictionaries into tables.
from tabulate import tabulate
msg_string = f'>>> `?`?`?prolog
{tabulate(list(sorted_stocks.items()),
headers=("Stock Ticker", "Mentions"),
tablefmt="fancy_grid")}
`?`?`?' # sorted_stocks is a dict
#send message
looks like this with the prolog discord markdown, you can change tablefmt argument or the discord markdown language to get different looks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…