How can I display strings on multiple lines?

2019-08-14 06:33发布

I am writing a "High Scores" table window for my pygame. Currently I am unpickling a file and then breaking the tuples apart so I can display the player name on the left and the score on the right. However in the current configuration, all of the player names are stacked ontop of eachother and the same with the scores. I need to figure out how to display each new player name and score combo on a new line. I'm still pretty new to python (working with version 3), any help would be greatly appreciated!

for x in high_scores:
    (Playername, score) = (x[0], x[1])
    print(Playername)
    Playername = Playername.rjust(25, " ")
    score = str(score)
    score = score.rjust(50, " ")
    megastring = megastring + Playername
    megastring = megastring + score

    Playersurface = myfont.render(str(Playername), True, (0, 0, 0))
    HighScoreScreen.blit(Playersurface,(0,0))
    scoresurface = myfont.render(str(score), True, (0, 0, 0))
    HighScoreScreen.blit(scoresurface,(0,0))

Thanks!

0条回答
登录 后发表回答