如何在python中打印和操作

如何在python中打印和操作,python,python-behave,Python,Python Behave,我还通过定义变量使用了其他打印方式 @then('I should be able to able to print with id "{el_id}"') def step_impl(context, el_id): if is_element_id_there(context, 'el_id'): print(get_element_text_id(context, 'el_id')) else: raise Exception('Elemen

我还通过定义变量使用了其他打印方式

@then('I should be able to able to print with id "{el_id}"')
def step_impl(context, el_id):
    if is_element_id_there(context, 'el_id'):
        print(get_element_text_id(context, 'el_id'))
    else:
        raise Exception('Element with id: ' + el_id + ' not found')

注意:我已经在我的bash配置文件中添加了
--无颜色
--无捕获

在打印结束时添加新行:

@then('I should be able to able to print with id "{el_id}"')
def step_impl(context, el_id):
    if is_element_id_there(context, 'el_id'):
        var = get_element_text_id(context, 'el_id')
        print(var)
    else:
        raise Exception('Element with id: ' + el_id + ' not found')


您是否添加了behave.ini文件?
print(get_element_text_id(context, 'el_id') + '\n')
var = get_element_text_id(context, 'el_id')
print(var + '\n')