传递变量时出现导入错误

时间:2015-10-25 23:08:56

标签: python python-3.x import python-import importerror

我收到了fuelCost和amountEarned的导入错误。我不明白为什么。

这是错误:

  

File" /Users/johndoe/Desktop/A5/driverModule.py" ;,第3行,在       来自TripInfoModule import fuelCost,amountEarned,netIncome,totalDrivingTime,totalBreakTime,totalDistance,totalFuelConsumed,getTotalDrivingTime   ImportError:无法导入名称' fuelCost'

def fuelCost():

    fuelConsumed = getFuelConsumed()
    costPerGallon = getCostperGallon()
    totalFuelCost = controller()

    gasUsed = float(fuelConsumed)
    costPerGal = float(costPerGallon)

    fuelCost = gasUsed * costPerGal
    totalFuelCost += fuelCost

    print("Your total fuel cost is:", format(fuelCost, '.2f'))

    return fuelCost, totalFuelCost


def amountEarned():

    distance = getDistance()
    earnings = getEarningpPerMile()
    totalAmountEarned = controller()

    distanceVar = float(distance)
    earningsVar = float(earnings)

    amountEarned = distanceVar * earningsVar
    totalAmountEarned += amountEarned

    print("Your earnings are:", format(amountEarned, '.2f'))

    return amountEarned, totalAmountEarned


def netIncome():

    fuelCost = fuelCost()
    amountEarned = amountEarned()
    totalNetIncome = controller()

    taxAmount = amountEarned * .08
    netIncome = (amountEarned - taxAmount) - fuelCost

    totalNetIncome += netIncome

    print("Your net income is:", format(netIncome, '.2f'))

    return netIncome

0 个答案:

没有答案