しょっちゅう忘れることを書いておく。
![]() |
66 |
1471 views
pythonで色付き文字を出力したい場合は、coloramaを使うと楽。
肝はcolorama.init()とcolorma.deinit()を呼び出すこと。
# coding:UTF-8
import colorama
# 初期化。呼び出さないと動かない
colorama.init()
# 文字色テスト
print(colorama.Fore.RED + "赤色文字")
print("白にはならず赤になる")
print(colorama.Style.RESET_ALL, end="")
print("今度は白になる")
print(colorama.Fore.GREEN + "緑色文字")
print(colorama.Fore.BLUE + "青色文字")
colorama.deinit()
実行結果のキャプチャ配下です。
Page 14 of 69.
すぺぺぺ
本サイトの作成者。
プログラムは趣味と勉強を兼ねて、のんびり本サイトを作っています。
フレームワークはdjango。
ChatGPTで自動プログラム作成に取り組み中。
https://www.osumoi-stdio.com/novel/