Python3 : ใส่สีให้ Text Mode Application
ใช้ colorama
ตัวอย่าง 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 ก็ย่อมได้
เขียนโดย
ครูชลิตา จูมสีมา
ตัวอย่าง 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 ก็ย่อมได้
![]() |
ผลลัพธ์ |
เขียนโดย
ครูชลิตา จูมสีมา
ความคิดเห็น
แสดงความคิดเห็น