pythonista3のコンソール画面をクリアする。
3617 ワード
Pythonista3でコンソール画面をクリアしたかったので調べたら、フォントやフォントサイズもフォントカラーも変更できることがわかりました。
サンプルコード
import console
# コンソール画面をクリア
console.clear()
# フォントとフォントサイズを変更
console.set_font('Menlo',24)
# フォントカラーを変更
console.set_color(255,255,0)
print('Hello')
# デフォルトに戻す
console.set_font()
console.set_color()
print('Hello')
# 1文字ずつ指定することも可能です。
S='Hello'
console.set_font('Zapfino',48)
for i,c in enumerate(S,1):
R, G, B = i&4 and 255, i&2 and 255, i&1 and 255
console.set_color(R,G,B)
print(c,end='')
'''
for i in range(1,6):
C=bin(i)[2:].zfill(3)
R=int(C[0]*255)
G=int(C[1]*255)
B=int(C[2]*255)
console.set_color(R,G,B)
print(S[i-1],end='')
# デフォルトに戻す
console.set_font()
console.set_color()
実行結果
Author And Source
この問題について(pythonista3のコンソール画面をクリアする。), 我々は、より多くの情報をここで見つけました https://qiita.com/maboy/items/063dcf1470c56d942fd1著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .