import math
gradient = ('FF24E9', 'F026EC', 'E128F0', 'D22AF3', 'C32CF7', 'A530FE', '8F3EFE', '7A4CFE', '655AFE', '5068FE', '3B76FE')
def gradientmadness(text):
leng = len(text)
output = ''
if leng < 11:
for i in range(0, leng):
output += '<c=#%s>' % gradient[i]
for i in range(0, leng):
output += text[i] + '</c>'
else :
output += '<c=#'
output += '><c=#'.join(gradient)
output += '>'
size = int(math.ceil(leng / 11.0))
for i in range(1, 11 + 1):
output += text[(i - 1) * size: i * size] + '</c>'
return output
gradientmadness.command = "gradient1"
答案 0 :(得分:0)
以下是具有正确格式的代码:
import math
gradient = ('FF24E9', 'F026EC', 'E128F0', 'D22AF3', 'C32CF7', 'A530FE', '8F3EFE', '7A4CFE', '655AFE', '5068FE', '3B76FE')
def gradientmadness(text):
leng = len(text)
output = ''
if leng < 11:
for i in range(0, leng):
output += '<c=#%s>' % gradient[i]
for i in range(0, leng):
output += text[i] + '</c>'
else :
output += '<c=#'
output += '><c=#'.join(gradient)
output += '>'
size = int(math.ceil(leng / 11.0))
for i in range(1, 11 + 1):
output += text[(i - 1) * size: i * size] + '</c>'
return output
gradientmadness.command = "gradient1"