Python3 : ใส่สีให้ Text Mode Application

ใช้ colorama



ตัวอย่าง Code
Code ตัวอย่าง


from colorama import init,Fore, Back, Style
init(autoreset=True)# reset to default after end print() command
#from termcolor import colored #ไม่ทำงานบน windows 10
#from colorama import

#print (colored("Teerasak",'red'))
print(Fore.RED + 'Teerasak')
print(Back.GREEN + 'some red text')
print('AfterGreen')
#print(Back.GREEN + 'and with a green background')
#print(Style.DIM + 'and in dim text')
#print(Style.RESET_ALL)
print('back to normal now')


ผลลัพธ์

หรือจะใช้คู่กับ termcolor module ก็ย่อมได้



ผลลัพธ์



เขียนโดย
ครูชลิตา จูมสีมา

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

CASIO fx-5800P : การ mod ด้วยเครื่องคิดเลข

sgsBB(SGS-Score Inserter) : โปรแกรมช่วยกรอกผลคะแนนจาก bookmark51 ใส่ระบบ SGS ของ สพฐ.

springMVC : เชื่อมต่อฐานข้อมูล mySQL ด้วย JDBC-Template