我在烧瓶中有一条路线,我用它来通过http将多个变量传递给我的函数。一切都很好,除了" biz"变量。这是我的功能...
@app.route("/sendcheck/<name>/<address_object>/<amount>/<memo>/<biz>", methods=['GET', 'POST'])
def create_check(name, address_object, amount, memo, biz):
check = lob.Check.create(
description = 'Check for {}'.format(name),
to_address = address_object,
from_address = biz.address,
bank_account = biz.bank,
amount = amount,
memo = memo,
logo = open(biz_0.logo, 'rb'),
check_bottom = '<h1 style="padding-top:4in;">{{name}}, attached is your check', #add a custom bottom
data = {
'name': name
}
)
biz
变量访问具有各种属性的类。因此,如果变量的值为biz_1
,则输入biz.address
应与biz_1.address
相同,但它不起作用。我得到了......
AttributeError: 'unicode' object has no attribute 'address'
我在这里做错了什么?
答案 0 :(得分:0)
这远非理想,但这就是我解决它的方式。我愿意接受建议。
@app.route("/sendcheck/<name>/<address_object>/<amount>/<memo>/<biz>", methods=['GET', 'POST'])
def create_check(name, address_object, amount, memo, biz):
if biz == 'biz_0':
biz = biz_0
elif biz == 'biz_1':
biz = biz_1
elif biz == 'biz_2':
biz = biz_2
elif biz == 'biz_3':
biz = biz_3
check = lob.Check.create(
description = 'Check for {}'.format(name),
to_address = address_object,
from_address = biz.address,
bank_account = biz.bank,
amount = amount,
memo = memo,
logo = open(biz_0.logo, 'rb'),
check_bottom = '<h1 style="padding-top:4in;">{{name}}, attached is your check', #add a custom bottom
data = {
'name': name
}
)