简体   繁体   中英

Combining python print statements

Is it possible to combine the the following two statements into one?

print(colored(score,"green"),end=" ")
print(colored(tokens,"green"))

是的,只需将最后一项添加到第一个打印语句中:

print(colored(score,"green"), colored(tokens,"green"))

As they're both green you can combine the strings and then colour them:

output = '{} {}'.format(score, tokens)
print(colored(output, 'green'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM