gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 18:29:37 25 4
gpt4 key购买 nike

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

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com