为什么下面的代码抛出typeError?

时间:2018-08-01 14:39:14

标签: python python-3.x python-2.7

class Car:
    def __init__(self, mileage, make, model):
        self.mileage = mileage
        self.make = make
        self.model = model

    def printCar(self):
        return "The Model is:" + self.model + " the make is: " + self.make + " and the mileage is: " + self.mileage


car = Car(100, 'Suzuki', 'Brezza')

print(car.printCar())

出现错误: 返回“模型为:” + self.model +”品牌为:“ + self.make +”,里程为:” + self.mileage TypeError:必须为str,而不是int

请帮助,我是python的初学者...

1 个答案:

答案 0 :(得分:1)

"scripts": [
   "src/assets/scripts/test1.js",
   "src/assets/scripts/test2.js"
]

请注意,将<channel id="startChannel"> <queue message-store="channelStore" /> </channel> <bridge input-channel="startChannel" output-channel="routerChannel" /> <channel id="routerChannel"> <queue message-store="channelStore" /> </channel> <int:router input-channel="routerChannel" expression="payload.status"> <int:mapping value="chunk completed" channel="loadData" /> <int:mapping value="job completed" channel="aggregateData" /> <int:mapping value="Failed" channel="errorChannel" /> </int:router> <task:executor id="workerThreadExecutor" pool-size="8" queue-capacity="40" rejection-policy="DISCARD" /> <channel id="loadData"> <dispatcher task-executor="workerThreadExecutor" /> </channel> <service-activator id="dataServiceActivator" input-channel="loadData" method="loadUserDetails" output-channel="aggregateData"> <beans:bean class="com.sample.DataServiceActivator" /> </service-activator> <channel id="aggregateData"> <queue message-store="channelStore" /> </channel> <aggregator id="aggregator" input-channel="aggregateData" output-channel="completionChannel" release-strategy="releaseStrategyBean" release-strategy-method="canRelease" correlation-strategy-expression="headers.userId" ref="aggregatorBean" method="aggregateChunks" send-partial-result-on-expiry="true" message-store="persistentMessageStore" expire-groups-upon-completion="true" group-timeout="7200000" expire-groups-upon-timeout="true" lock-registry="lockRegistry" /> <!-- -- releaseStrategyBean - release when data count equals to total data sent by 'Job Completed' message. -- aggregatorBean - with aggregated messages generates a report - batch job - could take some time to complete. --> <channel id="completionChannel"> <queue message-store="channelStore" /> </channel> 转换为def printCar(self): return "The Model is:" + self.model + " the make is: " + self.make + " and the mileage is: " + str(self.mileage) 的{​​{1}}函数。

相关问题