python turtle : How to use the write function to join an integer and a string with the integer coming from a list

标签 python string list integer turtle-graphics

所以,我试图让成绩能够在与我书写成绩时完全相同的行中打印百分号。

目标是打印:第一个示例为 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/

相关文章:

Java正则表达式从URL解析特定分号分隔的参数?

list - Prolog:取列表的前 "N"个元素

java - 将字符串[]作为字节[]传递

python - 如何在 Django 请求处理程序线程中对 SIGTERM 执行代码

python - 通过添加行以不同的增量对 Pandas DataFrame 进行插值

Python导入模块依赖

android - 如何从 SafeArgs 中的资源中获取默认字符串值?

javascript - 循环故障的二进制转换器

python - 将值分配给超出范围的索引列表

python - 如何检查元组或列表中的所有元素是否都在另一个元组或列表中?