如何在python中打印并表现出来

时间:2017-08-08 06:15:58

标签: 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('Element with id: ' + el_id + ' not found')

我还通过定义变量

使用其他打印方式
@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')

注意:我已在我的bash个人资料中添加了--no-colors--no-capture

1 个答案:

答案 0 :(得分:1)

在打印结束时添加换行符:

print(get_element_text_id(context, 'el_id') + '\n')

var = get_element_text_id(context, 'el_id')
print(var + '\n')