尝试使用id()函数获取对象的ID时出现类型错误

时间:2019-09-18 05:11:19

标签: python-3.x typeerror

首先,当我尝试在下面的代码中打印对象't'的ID时,出现错误,提示为' TypeError:'int'对象不可调用'。其次,虽然我使用的对象是一个元组,但我想知道为什么错误消息将其读取为'int'

代码:

async function fetchCoverageData() {
  if (!coverageData.host || !coverageData.project ||
      !coverageData.change || !coverageData.patchset) {
    throw 'Need retry, change info is unavailable yet for code coverage.';
  }

  console.log('coverage data reached here is', coverageData);  
  const url = REQUEST_BASE_URL + coverageData.project + "/" + coverageData.branch + "/" + coverageData.changeId;

  const response = await fetch(url);
  const responseJson = await response.json();

  if (responseJson.error) {
    console.error('Parse response body to JSON returned ' +
                  'error: ', responseJson.error);
    return null;
  }
  if (response.status == 404 &&
      responseJson.is_project_supported == false) {
    console.warn(' project is not supported for code coverage.');
    return null;
  }
  if (response.status == 500 &&
      responseJson.is_service_enabled == false) {
    console.warn('service is temporarily disabled.');
    return null;
  }
  if (!response.ok) {
    throw `Need retry, request code coverage data returned http ` +
          `${response.status}.`;
  }
  return responseJson;
}

错误消息:

t = ('A', 'B')
print(id(t))

即使是以下代码

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-113-7ddf37e10fd6> in <module>
      1 t = ('A', 'B')
----> 2 print(id(t))
      3 
      4 t1 = ('A', 'B')
      5 print(id(t1))

TypeError: 'int' object is not callable

我收到与上述相同的错误消息。

0 个答案:

没有答案