所以,我试图让成绩能够在与我书写成绩时完全相同的行中打印百分号。
目标是打印:第一个示例为 45%。
from turtle import *
grades = [45, 42, 13, 98, 82]
write(grades[0],'%')
当我运行此代码时,成绩和百分号都会打印在彼此的顶部。如何并排获得成绩和百分号而不使两者重叠?
最佳答案
尝试使用字符串format
方法:
write("{0}%".format(grades[1]))
关于 python turtle : How to use the write function to join an integer and a string with the integer coming from a list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22577550/