每当我尝试使用Python的exponentiation和logarithms模块的任何内置函数时,我都会收到如下错误:
NameError: name 'sqrt' is not defined
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用math.sqrt(4),sqrt(4)和sqrt(4.0),但他们没有工作.例外情况是pow,它应该按预期工作.这真的很奇怪,我不确定是什么问题.
use strict;
my @array = ();
my @nums = [3, 4];
foreach my $i ( 0 .. 10 ) {
foreach my $j ( 0 .. 10 ) {
$nums[0] = 4+1;
push @{ $array[$i] }, @nums;
}
}
print $array[6][2][0]. "\n";
Run Code Online (Sandbox Code Playgroud)
正如人们可以看到他们是否运行代码,这不能正常运行.但是,如果你注释掉"$ nums [0] = 4 + 1;"这一行,它运行正常.到底是怎么回事?只能将不可变数组推送到其他数组吗?