How to put variable into a label text?
问题 I wrote a tkinter code, with a label. There was a variable in the label text. lab = Label(root, text = 'randomstrings', x, 'randomstrings') lab.pack() When I ran the code, it gave an error message here: , x, It said: positional argument follows keyword argument 回答1: You must put all label pieces together before passing them to the Label : Label(root, text = 'randomstrings' + str(x) + 'randomstrings', ...) or: Label(root, text = 'randomstrings{}randomstring'.format(x), ...) 回答2: Using commas