from Tkinter import *
root = Tk()
#左对齐,文本居中
Label(root,
text = 'welcome to jcodeer.cublog.cn',
bg = 'yellow',
width = 40,
height = 3,
wraplength = 80,
justify = 'left'
).pack()
#居中对齐,文本居左
Label(root,
text = 'welcome to jcodeer.cublog.cn',
bg = 'red',
width = 40,
height = 3,
wraplength = 80,
anchor = 'w'
).pack()
#居中对齐,文本居右
Label(root,
text = 'welcome to jcodeer.cublog.cn',
bg = 'blue',
width = 40,
height = 3,
wraplength = 80,
anchor = 'e'
).pack()
root.mainloop()
'''
输出结果,justify 与 anchor 的区别了:一个用于控制多行的对齐;另一个用于控制整个文本
块在 Label 中的位置
'''