文字列を右揃えにする方法を探しています。これは私のコードです:
from graphics import*
def main():
win = GraphWin("Simple Editor", 600, 400)
win.setCoords(0,0,60,40)
#Text - Filename
s = "File Name:"
s=s.rjust(10)
text1 = Text(Point(10, 35), s)
text1.draw(win)
#Text - Keyword
s1 = "Keyword:"
s1=s1.rjust(8)
text2 = Text(Point(10, 28), s1)
text2.draw(win)
#Text - Replace with
s2 = "Replace with:"
s2=s2.rjust(10)
text2 = Text(Point(10, 21), s2)
text2.draw(win)`
main()
コマンドは.rjust()
何もないようです。私がプログラムを実行すると、彼らはまだ私が与えたポイントにテキストを中央揃えしており、そのポイントを正しく正当化していません。これに対する解決策が見つかりません。助けてください!