在Python中,可以通过打印变量的类型来分析数据类型来调试程序,例如
print type(test_var)
朱莉娅有类似的东西吗?我在为二维数组赋值时遇到问题,并且知道每个变量的确切类型会有所帮助.
我有一个python脚本,script.py并使用cron定期运行此脚本.脚本按预期运行,但是一旦cron作业完成,我在/ var/mail/[myusername]中收到以下错误:
sh: sysctl Command Not Found
以下是cron工作:
0 14 * * * PATH=$PATH:/usr/sbin PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ /usr/bin/python2.7 ~/.../script.py
Run Code Online (Sandbox Code Playgroud)
我被告知在任务中包含PATH和PYTHONPATH(如前所述,python不会识别我导入和安装的几个模块),所以此时我不确定问题是什么
我正在尝试通过阅读文档来学习Julia,他们的代码看起来像这样:
function testFunction(x::Number)
return x+5
end
Run Code Online (Sandbox Code Playgroud)
这是一个适用于Juila中许多数字类型的函数.
但是,如果我尝试做类似的事情,像这样:
function testFunction2(x::Array{Number})
return x
end
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ERROR: MethodError: no method matching testFunction2(::Array{Int64,1})
Closest candidates are:
testFunction2(::Array{Number,N} where N) at /Users/.../Desktop/Test.jl:45
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?我想这是:Array{Float64}你是如何声明一个特定类型的数组,但是使用类似的类型Number,它适用于常规情况,在这里不起作用...任何见解都值得赞赏.
我目前正在尝试测试 Vector 类实现,并尝试使用 GDB 来查看错误发生的位置。
当我使用以下内容编译gcc -ggdb Vector.c TestVector.c并随后在 GDB 中运行它时,我得到以下输出(在崩溃并尝试打印堆栈跟踪之后):
| => gdb ./a.out
Reading symbols from ./a.out...Reading symbols from /Users/prog/Desktop/Generics/a.out.dSYM/Contents/Resources/DWARF/a.out...done.
done.
(gdb) r
Starting program: /Users/prog/Desktop/Generics/a.out
[New Thread 0x2703 of process 56984]
warning: unhandled dyld version (15)
Thread 2 received signal SIGSEGV, Segmentation fault.
0x00007fff65d97fe6 in ?? ()
(gdb) bt
#0 0x00007fff65d97fe6 in ?? ()
#1 0x00007ffeefbff640 in ?? ()
#2 0x00007fff65be4139 in ?? ()
#3 0x00007ffeefbff660 in ?? ()
#4 0x0000000000000000 in ?? ()
Run Code Online (Sandbox Code Playgroud)