在写代码时,出现了警告,然后我查了一下相关资料才知道原因。
今天将该学到的知识点记录下来

警告:This inspection detects shadowing built-in names, such as ‘len’ or ‘list’.

list()是内置函数

警告的原因:
若使用内置函数的名字作为变量名,Python 解释器倒不会报错,只是该内置函数就被这个变量覆盖了,该内置函数就不能使用了。一般只会警告。所以内置函数的名字不应该作为变量名,否则 Python 的内置函数会被覆盖。

在写代码时,出现下代码出现警告提示
python3 警告:This inspection detects shadowing built-in names, such as 'len' or 'list'.

代码警告原因
python3 警告:This inspection detects shadowing built-in names, such as 'len' or 'list'.

python3 警告:This inspection detects shadowing built-in names, such as 'len' or 'list'.
注解:在 Python 2.x 中,print 是关键字而不是函数。上面这些内置函数(如 unicode())只是 Python 2.x 的内置函数,为了保证 Python 程序具有更好的兼容性,程序也不应该使用这些内置函数的名字作为标识符。

相关文章:

  • 2021-05-09
  • 2022-12-23
  • 2021-08-03
  • 2021-04-05
  • 2021-11-26
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-06
  • 2021-10-31
  • 2022-01-13
  • 2021-07-16
  • 2021-08-24
  • 2022-12-23
相关资源
相似解决方案