Изменение цвета невозможно с PrettyPrint, но вы можете применить свою собственную постобработку:
import re
import requests
from prettytable import PrettyTable
def market_table():
changes = []
data = requests.get('https://api.coinmarketcap.com/v2/ticker').json()['data']
table = PrettyTable(['Name', 'Market Cap', 'Price', 'Change 1h', 'Change 24h', 'Change 7d'], sortby='Market Cap', reversesort=True)
for currency in data:
change_1h = data[currency]['quotes']['USD']['percent_change_1h']
change_24h = data[currency]['quotes']['USD']['percent_change_24h']
change_7d = data[currency]['quotes']['USD']['percent_change_7d']
changes.extend([change_1h, change_24h, change_7d])
table.add_row([data[currency]['name'], data[currency]['quotes']['USD']['market_cap'],
data[currency]['quotes']['USD']['price'], change_1h, change_24h, change_7d])
html = table.get_html_string()
for change in changes:
color = '#00FF00' if change > 0 else '#FF0000'
html = re.sub('<td>{}</td>'.format(change), '<td bgcolor="{}">{}</td>'.format(color, change), html)
return html
Вот что вы получите: