How can I display strings on multiple lines?

六月ゝ 毕业季﹏ 提交于 2019-12-24 06:31:11

问题


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!

来源:https://stackoverflow.com/questions/46678084/how-can-i-display-strings-on-multiple-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!