无法访问 JIRA 项目的“来自”属性

问题描述

我试图在访问 JIRA 时访问项目的 from 属性。 Python 给了我一个语法错误。可能是什么问题?

for history in changelog.histories:
    for item in history.items:
        if (item.field.upper() == 'SPRINT'):
            try:
                if item.fromString:
                    sFromSprint = str(100) #python does not like item.from
                else:
                    sFromSprint = str(iZERO)    

错误

    iFromSprint = item.from
                       ^
SyntaxError: invalid Syntax

解决方法

from 是python中的保留关键字

您可以使用 getattr(item,'from') 来获取属性。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...