/ Tipos de operandos não suportados para /: 'unicode' e 'int' - python, int, jython, bukkit, operando

Tipos de operandos não suportados para /: 'unicode' e 'int' - python, int, jython, bukkit, operando

Primeiro de tudo, desculpe por fazer duas perguntas emintervalo curto, mas eu resolvi o último, então eu preciso de ajuda novamente. Eu estou codificando plugins bukkit com jython / python ... Sou muito novo em python / jython e não entendo onde estou me enganando, veja o código:

(everything is under class hween(PythonPlugin))
def CandyChance(self):
chance = self.cfg.getString("main.candydropchance") #this works, I tried to print it and result is 10 (which I entered in config before)
chancetotal = chance / 100

@hook.event("block.BlockBreakEvent", "HIGHEST")
def onBlockBreakEvent(event):
#something
chancetotal = pyplugin.CandyChance()
if("Random.nextDouble() <= %s"%chancetotal):
#do something

Obrigado!

Respostas:

2 para resposta № 1

"Imprime 10" não diz nada sobre o tipo que é. É provavelmente a cadeia "10" e não o número 10 - como você pode imaginar a partir do nome do método getString. Você não pode dividir uma string por um número. Tente fazer:

chance = int(self.cfg.getString("main.candydropchance"))