當我嘗試運行這個程序(下面的代碼),它返回一個TypeError: 'int' object is not callable
'int'對象不可調用?
代碼:
import random
import math
def var():
strength = 10
skill = 10
dice4 = 0
dice12 = 0
character_name = str(input("Please enter your characters name: "))
skill(strength, skill, dice4, dice12, character_name)
def skill(strength, skill, dice4, dice12, character_name):
print(character_name + "'s attributes are being generated! ... ")
dice4, dice12 = random.randrange(1,4), random.randrange(1,12)
dice_score = dice12/dice4
dice_score = math.floor(dice_score)
skill = skill + dicescore
strength(strength, skill, dice4, dice12, character_name)
def strength(strength, skill, dice4, dice12, character_name):
dice4, dice12 = random.randrange(1,4), random.randrange(1,12)
dice_score = dice12/dice4
dice_score = math.floor(dice_score)
strength = strength + dicescore
file(strength, skill, dice4, dice12, character_name)
def file(strength, skill, dice4, dice12, character_name):
file = open("N:\Controlled Assessment - Ryan Harper\Task Two\attributes.txt", w)
file.writelines(character_name + " - Strength = " + str(strength) + ", Skill = " + str(skill))
var()
錯誤:
Traceback (most recent call last):
File "N:\Controlled Assessment - Ryan Harper\Task Two\task 2 v2.py", line 37, in <module>
var()
File "N:\Controlled Assessment - Ryan Harper\Task Two\task 2 v2.py", line 11, in var
skill(strength, skill, dice4, dice12, character_name)
TypeError: 'int' object is not callable