- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章Python代码调试的几种方法总结由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
使用 pdb 进行调试 。
pdb 是 python 自带的一个包,为 python 程序提供了一种交互的源代码调试功能,主要特性包括设置断点、单步调试、进入函数调试、查看当前代码、查看栈片段、动态改变变量的值等。pdb 提供了一些常用的调试命令,详情见表 1。 表 1. pdb 常用命令 。
下面结合具体的实例讲述如何使用 pdb 进行调试。 清单 1. 测试代码示例 。
1
2
3
4
5
6
7
|
import
pdb
a
=
"aaa"
pdb.set_trace()
b
=
"bbb"
c
=
"ccc"
final
=
a
+
b
+
c
print
final
|
开始调试:直接运行脚本,会停留在 pdb.set_trace() 处,选择 n+enter 可以执行当前的 statement。在第一次按下了 n+enter 之后可以直接按 enter 表示重复执行上一条 debug 命令。 清单 2. 利用 pdb 调试 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb1.py
>
/
root
/
epdb1.py(
4
)?()
-
> b
=
"bbb"
(Pdb) n
>
/
root
/
epdb1.py(
5
)?()
-
> c
=
"ccc"
(Pdb)
>
/
root
/
epdb1.py(
6
)?()
-
> final
=
a
+
b
+
c
(Pdb)
list
1
import
pdb
2
a
=
"aaa"
3
pdb.set_trace()
4
b
=
"bbb"
5
c
=
"ccc"
6
-
> final
=
a
+
b
+
c
7
print
final
[EOF]
(Pdb)
[EOF]
(Pdb) n
>
/
root
/
epdb1.py(
7
)?()
-
>
print
final
(Pdb)
|
退出 debug:使用 quit 或者 q 可以退出当前的 debug,但是 quit 会以一种非常粗鲁的方式退出程序,其结果是直接 crash。 清单 3. 退出 debug 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb1.py
>
/
root
/
epdb1.py(
4
)?()
-
> b
=
"bbb"
(Pdb) n
>
/
root
/
epdb1.py(
5
)?()
-
> c
=
"ccc"
(Pdb) q
Traceback (most recent call last):
File
"epdb1.py"
, line
5
,
in
?
c
=
"ccc"
File
"epdb1.py"
, line
5
,
in
?
c
=
"ccc"
File
"/usr/lib64/python2.4/bdb.py"
, line
48
,
in
trace_dispatch
return
self
.dispatch_line(frame)
File
"/usr/lib64/python2.4/bdb.py"
, line
67
,
in
dispatch_line
if
self
.quitting:
raise
BdbQuit
bdb.BdbQuit
|
打印变量的值:如果需要在调试过程中打印变量的值,可以直接使用 p 加上变量名,但是需要注意的是打印仅仅在当前的 statement 已经被执行了之后才能看到具体的值,否则会报 NameError: < exceptions.NameError … ....> 错误。 清单 4. debug 过程中打印变量 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb1.py
>
/
root
/
epdb1.py(
4
)?()
-
> b
=
"bbb"
(Pdb) n
>
/
root
/
epdb1.py(
5
)?()
-
> c
=
"ccc"
(Pdb) p b
'bbb'
(Pdb)
'bbb'
(Pdb) n
>
/
root
/
epdb1.py(
6
)?()
-
> final
=
a
+
b
+
c
(Pdb) p c
'ccc'
(Pdb) p final
*
*
*
NameError: <exceptions.NameError instance at
0x1551b710
>
(Pdb) n
>
/
root
/
epdb1.py(
7
)?()
-
>
print
final
(Pdb) p final
'aaabbbccc'
(Pdb)
|
使用 c 可以停止当前的 debug 使程序继续执行。如果在下面的程序中继续有 set_statement() 的申明,则又会重新进入到 debug 的状态,读者可以在代码 print final 之前再加上 set_trace() 验证。 清单 5. 停止 debug 继续执行程序 。
1
2
3
4
5
6
7
8
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb1.py
>
/
root
/
epdb1.py(
4
)?()
-
> b
=
"bbb"
(Pdb) n
>
/
root
/
epdb1.py(
5
)?()
-
> c
=
"ccc"
(Pdb) c
aaabbbccc
|
显示代码:在 debug 的时候不一定能记住当前的代码块,如要要查看具体的代码块,则可以通过使用 list 或者 l 命令显示。list 会用箭头 -> 指向当前 debug 的语句。 清单 6. debug 过程中显示代码 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb1.py
>
/
root
/
epdb1.py(
4
)?()
-
> b
=
"bbb"
(Pdb)
list
1
import
pdb
2
a
=
"aaa"
3
pdb.set_trace()
4
-
> b
=
"bbb"
5
c
=
"ccc"
6
final
=
a
+
b
+
c
7
pdb.set_trace()
8
print
final
[EOF]
(Pdb) c
>
/
root
/
epdb1.py(
8
)?()
-
>
print
final
(Pdb)
list
3
pdb.set_trace()
4
b
=
"bbb"
5
c
=
"ccc"
6
final
=
a
+
b
+
c
7
pdb.set_trace()
8
-
>
print
final
[EOF]
(Pdb)
|
在使用函数的情况下进行 debug 清单 7. 使用函数的例子 。
1
2
3
4
5
6
7
8
9
10
11
|
import
pdb
def
combine(s1,s2):
# define subroutine combine, which...
s3
=
s1
+
s2
+
s1
# sandwiches s2 between copies of s1, ...
s3
=
'"' + s3 +'"'
# encloses it in double quotes,...
return
s3
# and returns it.
a
=
"aaa"
pdb.set_trace()
b
=
"bbb"
c
=
"ccc"
final
=
combine(a,b)
print
final
|
如果直接使用 n 进行 debug 则到 final=combine(a,b) 这句的时候会将其当做普通的赋值语句处理,进入到 print final。如果想要对函数进行 debug 如何处理呢 ? 可以直接使用 s 进入函数块。函数里面的单步调试与上面的介绍类似。如果不想在函数里单步调试可以在断点处直接按 r 退出到调用的地方。 清单 8. 对函数进行 debug 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb2.py
>
/
root
/
epdb2.py(
10
)?()
-
> b
=
"bbb"
(Pdb) n
>
/
root
/
epdb2.py(
11
)?()
-
> c
=
"ccc"
(Pdb) n
>
/
root
/
epdb2.py(
12
)?()
-
> final
=
combine(a,b)
(Pdb) s
-
-
Call
-
-
>
/
root
/
epdb2.py(
3
)combine()
-
>
def
combine(s1,s2):
# define subroutine combine, which...
(Pdb) n
>
/
root
/
epdb2.py(
4
)combine()
-
> s3
=
s1
+
s2
+
s1
# sandwiches s2 between copies of s1, ...
(Pdb)
list
1
import
pdb
2
3
def
combine(s1,s2):
# define subroutine combine, which...
4
-
> s3
=
s1
+
s2
+
s1
# sandwiches s2 between copies of s1, ...
5
s3
=
'"' + s3 +'"'
# encloses it in double quotes,...
6
return
s3
# and returns it.
7
8
a
=
"aaa"
9
pdb.set_trace()
10
b
=
"bbb"
11
c
=
"ccc"
(Pdb) n
>
/
root
/
epdb2.py(
5
)combine()
-
> s3
=
'"' + s3 +'"'
# encloses it in double quotes,...
(Pdb) n
>
/
root
/
epdb2.py(
6
)combine()
-
>
return
s3
# and returns it.
(Pdb) n
-
-
Return
-
-
>
/
root
/
epdb2.py(
6
)combine()
-
>
'"aaabbbaaa"'
-
>
return
s3
# and returns it.
(Pdb) n
>
/
root
/
epdb2.py(
13
)?()
-
>
print
final
(Pdb)
|
在调试的时候动态改变值 。在调试的时候可以动态改变变量的值,具体如下实例。需要注意的是下面有个错误,原因是 b 已经被赋值了,如果想重新改变 b 的赋值,则应该使用! B。 清单 9. 在调试的时候动态改变值 。
1
2
3
4
5
6
7
8
9
|
[root@rcc
-
pok
-
idg
-
2255
~]
# python epdb2.py
>
/
root
/
epdb2.py(
10
)?()
-
> b
=
"bbb"
(Pdb) var
=
"1234"
(Pdb) b
=
"avfe"
*
*
*
The specified
object
'= "avfe"'
is
not
a function
or
was
not
found along sys.path.
(Pdb) !b
=
"afdfd"
(Pdb)
|
pdb 调试有个明显的缺陷就是对于多线程,远程调试等支持得不够好,同时没有较为直观的界面显示,不太适合大型的 python 项目。而在较大的 python 项目中,这些调试需求比较常见,因此需要使用更为高级的调试工具。接下来将介绍 PyCharm IDE 的调试方法 . 使用 PyCharm 进行调试 。
PyCharm 是由 JetBrains 打造的一款 Python IDE,具有语法高亮、Project 管理、代码跳转、智能提示、自动完成、单元测试、版本控制等功能,同时提供了对 Django 开发以及 Google App Engine 的支持。分为个人独立版和商业版,需要 license 支持,也可以获取免费的 30 天试用。试用版本的 Pycharm 可以在官网上下载,下载地址为:http://www.jetbrains.com/pycharm/download/index.html。 PyCharm 同时提供了较为完善的调试功能,支持多线程,远程调试等,可以支持断点设置,单步模式,表达式求值,变量查看等一系列功能。PyCharm IDE 的调试窗口布局如图 1 所示。 图 1. PyCharm IDE 窗口布局 。
下面结合实例讲述如何利用 PyCharm 进行多线程调试。具体调试所用的代码实例见清单 10。 清单 10. PyCharm 调试代码实例 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
__author__
=
'zhangying'
#!/usr/bin/python
import
thread
import
time
# Define a function for the thread
def
print_time( threadName, delay):
count
=
0
while
count <
5
:
count
+
=
1
print
"%s: %s"
%
( threadName, time.ctime(time.time()) )
def
check_sum(threadName,valueA,valueB):
print
"to calculate the sum of two number her"
result
=
sum
(valueA,valueB)
print
"the result is"
,result;
def
sum
(valueA,valueB):
if
valueA >
0
and
valueB>
0
:
return
valueA
+
valueB
def
readFile(threadName, filename):
file
=
open
(filename)
for
line
in
file
.xreadlines():
print
line
try
:
thread.start_new_thread( print_time, (
"Thread-1"
,
2
, ) )
thread.start_new_thread( check_sum, (
"Thread-2"
,
4
,
5
, ) )
thread.start_new_thread( readFile, (
"Thread-3"
,
"test.txt"
,))
except
:
print
"Error: unable to start thread"
while
1
:
# print "end"
pass
|
在调试之前通常需要设置断点,断点可以设置在循环或者条件判断的表达式处或者程序的关键点。设置断点的方法非常简单:在代码编辑框中将光标移动到需要设置断点的行,然后直接按 Ctrl+F8 或者选择菜单"Run"->"Toggle Line Break Point",更为直接的方法是双击代码编辑处左侧边缘,可以看到出现红色的小圆点(如图 2)。当调试开始的时候,当前正在执行的代码会直接显示为蓝色。下图中设置了三个断点,蓝色高亮显示的为正在执行的代码。 图 2. 断点设置 。
表达式求值:在调试过程中有的时候需要追踪一些表达式的值来发现程序中的问题,Pycharm 支持表达式求值,可以通过选中该表达式,然后选择“Run”->”Evaluate Expression”,在出现的窗口中直接选择 Evaluate 便可以查看.
Pychar 同时提供了 Variables 和 Watches 窗口,其中调试步骤中所涉及的具体变量的值可以直接在 variable 一栏中查看。 图 3. 变量查看 。
如果要动态的监测某个变量可以直接选中该变量并选择菜单”Run”->”Add Watch”添加到 watches 栏中。当调试进行到该变量所在的语句时,在该窗口中可以直接看到该变量的具体值。 图 4. 监测变量 。
对于多线程程序来说,通常会有多个线程,当需要 debug 的断点分别设置在不同线程对应的线程体中的时候,通常需要 IDE 有良好的多线程调试功能的支持。 Pycharm 中在主线程启动子线程的时候会自动产生一个 Dummy 开头的名字的虚拟线程,每一个 frame 对应各自的调试帧。如图 5,本实例中一共有四个线程,其中主线程生成了三个线程,分别为 Dummy-4,Dummy-5,Dummy-6. 其中 Dummy-4 对应线程 1,其余分别对应线程 2 和线程 3。 图 5. 多线程窗口 。
当调试进入到各个线程的子程序时,Frame 会自动切换到其所对应的 frame,相应的变量栏中也会显示与该过程对应的相关变量,如图 6,直接控制调试按钮,如 setp in,step over 便可以方便的进行调试。 图 6. 子线程调试 。
使用 PyDev 进行调试 。
PyDev 是一个开源的的 plugin,它可以方便的和 Eclipse 集成,提供方便强大的调试功能。同时作为一个优秀的 Python IDE 还提供语法错误提示、源代码编辑助手、Quick Outline、Globals Browser、Hierarchy View、运行等强大功能。下面讲述如何将 PyDev 和 Eclipse 集成。在安装 PyDev 之前,需要先安装 Java 1.4 或更高版本、Eclipse 以及 Python。 第一步:启动 Eclipse,在 Eclipse 菜单栏中找到 Help 栏,选择 Help > Install New Software,并选择 Add button,添加 Ptdev 的下载站点 http://pydev.org/updates。选择 PyDev 之后完成余下的步骤便可以安装 PyDev。 图 7. 安装 PyDev 。
安装完成之后需要配置 Python 解释器,在 Eclipse 菜单栏中,选择 Window > Preferences > Pydev > Interpreter – Python。Python 安装在 C:\Python27 路径下。单击 New,选择 Python 解释器 python.exe,打开后显示出一个包含很多复选框的窗口,选择需要加入系统 PYTHONPATH 的路径,单击 OK。 图 8. 配置 PyDev 。
在配置完 Pydev 之后,可以通过在 Eclipse 菜单栏中,选择 File > New > Project > Pydev >Pydev Project,单击 Next 创建 Python 项目,下面的内容假设 python 项目已经创建,并且有个需要调试的脚本 remote.py(具体内容如下),它是一个登陆到远程机器上去执行一些命令的脚本,在运行的时候需要传入一些参数,下面将详细讲述如何在调试过程中传入参数 . 清单 11. Pydev 调试示例代码 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env python
import
os
def
telnetdo(HOST
=
None
, USER
=
None
, PASS
=
None
, COMMAND
=
None
):
#define a function
import
telnetlib, sys
if
not
HOST:
try
:
HOST
=
sys.argv[
1
]
USER
=
sys.argv[
2
]
PASS
=
sys.argv[
3
]
COMMAND
=
sys.argv[
4
]
except
:
print
"Usage: remote.py host user pass command"
return
tn
=
telnetlib.Telnet()
#
try
:
tn.
open
(HOST)
except
:
print
"Cannot open host"
return
tn.read_until(
"login:"
)
tn.write(USER
+
'\n'
)
if
PASS:
tn.read_until(
"Password:"
)
tn.write(PASS
+
'\n'
)
tn.write(COMMAND
+
'\n'
)
tn.write(
"exit\n"
)
tmp
=
tn.read_all()
tn.close()
del
tn
return
tmp
if
__name__
=
=
'__main__'
:
print
telnetdo()
|
在调试的时候有些情况需要传入一些参数,在调试之前需要进行相应的配置以便接收所需要的参数,选择需要调试的程序(本例 remote.py),该脚本在 debug 的过程中需要输入四个参数:host,user,password 以及命令。在 eclipse 的工程目录下选择需要 debug 的程序,单击右键,选择“Debug As”->“Debug Configurations”,在 Arguments Tab 页中选择“Variables”。如下 图 9 所示 . 图 9. 配置变量 。
在窗口”Select Variable”之后选择“Edit Varuables” ,出现如下窗口,在下图中选择”New” 并在弹出的窗口中输入对应的变量名和值。特别需要注意的是在值的后面一定要有空格,不然所有的参数都会被当做第一个参数读入。 图 10. 添加具体变量 。
按照以上方式依次配置完所有参数,然后在”select variable“窗口中安装参数所需要的顺序依次选择对应的变量。配置完成之后状态如下图 11 所示。 图 11. 完成配置 。
选择 Debug 便可以开始程序的调试,调试方法与 eclipse 内置的调试功能的使用相似,并且支持多线程的 debug,这方面的文章已经有很多,读者可以自行搜索阅读,或者参考”使用 Eclipse 平台进行调试“一文。 使用日志功能达到调试的目的 。
日志信息是软件开发过程中进行调试的一种非常有用的方式,特别是在大型软件开发过程需要很多相关人员进行协作的情况下。开发人员通过在代码中加入一些特定的能够记录软件运行过程中的各种事件信息能够有利于甄别代码中存在的问题。这些信息可能包括时间,描述信息以及错误或者异常发生时候的特定上下文信息。 最原始的 debug 方法是通过在代码中嵌入 print 语句,通过输出一些相关的信息来定位程序的问题。但这种方法有一定的缺陷,正常的程序输出和 debug 信息混合在一起,给分析带来一定困难,当程序调试结束不再需要 debug 输出的时候,通常没有很简单的方法将 print 的信息屏蔽掉或者定位到文件。python 中自带的 logging 模块可以比较方便的解决这些问题,它提供日志功能,将 logger 的 level 分为五个级别,可以通过 Logger.setLevel(lvl) 来设置。默认的级别为 warning。 表 2. 日志的级别 。
ogging lib 包含 4 个主要对象 。
清单 12. 日志使用示例 。
import logging LOG1=logging.getLogger('b.c') LOG2=logging.getLogger('d.e') filehandler = logging.FileHandler('test.log','a') formatter = logging.Formatter('%(name)s %(asctime)s %(levelname)s %(message)s') filehandler.setFormatter(formatter) filter=logging.Filter('b') filehandler.addFilter(filter) LOG1.addHandler(filehandler) LOG2.addHandler(filehandler) LOG1.setLevel(logging.INFO) LOG2.setLevel(logging.DEBUG) LOG1.debug('it is a debug info for log1') LOG1.info('normal infor for log1') LOG1.warning('warning info for log1:b.c') LOG1.error('error info for log1:abcd') LOG1.critical('critical info for log1:not worked') LOG2.debug('debug info for log2') LOG2.info('normal info for log2') LOG2.warning('warning info for log2') LOG2.error('error:b.c') LOG2.critical('critical') 。
上例设置了 filter b,则 b.c 为 b 的子 logger,因此满足过滤条件该 logger 相关的日志信息会 被输出,而其他不满足条件的 logger(这里是 d.e)会被过滤掉。 清单 13. 输出结果 。
b.c 2011-11-25 11:07:29,733 INFO normal infor for log1 b.c 2011-11-25 11:07:29,733 WARNING warning info for log1:b.c b.c 2011-11-25 11:07:29,733 ERROR error info for log1:abcd b.c 2011-11-25 11:07:29,733 CRITICAL critical info for log1:not worked 。
logging 的使用非常简单,同时它是线程安全的,下面结合多线程的例子讲述如何使用 logging 进行 debug。 清单 14. 多线程使用 logging 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
logging.conf
[loggers]
keys
=
root,simpleExample
[handlers]
keys
=
consoleHandler
[formatters]
keys
=
simpleFormatter
[logger_root]
level
=
DEBUG
handlers
=
consoleHandler
[logger_simpleExample]
level
=
DEBUG
handlers
=
consoleHandler
qualname
=
simpleExample
propagate
=
0
[handler_consoleHandler]
class
=
StreamHandler
level
=
DEBUG
formatter
=
simpleFormatter
args
=
(sys.stdout,)
[formatter_simpleFormatter]
format
=
%
(asctime)s
-
%
(name)s
-
%
(levelname)s
-
%
(message)s
datefmt
=
code example:
#!/usr/bin/python
import
thread
import
time
import
logging
import
logging.config
logging.config.fileConfig(
'logging.conf'
)
# create logger
logger
=
logging.getLogger(
'simpleExample'
)
# Define a function for the thread
def
print_time( threadName, delay):
logger.debug(
'thread 1 call print_time function body'
)
count
=
0
logger.debug(
'count:%s'
,count)
|
总结 。
全文介绍了 python 中 debug 的几种不同的方式,包括 pdb 模块、利用 PyDev 和 Eclipse 集成进行调试、PyCharm 以及 Debug 日志进行调试,希望能给相关 python 使用者一点参考。更多关于 python debugger 的资料可以参见参考资料.
最后此篇关于Python代码调试的几种方法总结的文章就讲到这里了,如果你想了解更多关于Python代码调试的几种方法总结的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
昨晚我因为这个问题脑子崩溃了。在确保没有来 self 的 eclipse 错误检查的明显错误之后,我开始调试我的程序。顺便说一下,我正在使用 Jre7。无论如何,每次我进入我的类调用(我们称之为“a”
(前言:我对 C/C++ 还很陌生,我真的不知道 native 代码中的调试实际上是如何工作的。) 一些消息来源说 gdb 和 lldb 可以调试 any program compiled to ma
我正在尝试从 Visual Studio 2012 外部调试 T4Scaffolding.Core Nuget 包。我使用的是安装了 Powershell 3.0 的 Powershell ISE,并
如何调试汇编代码?我在 Linux 上使用 gdb。我知道我可以看寄存器。有哪些调试汇编代码的方法? 最佳答案 您当然可以使用 breakpoints就像 C 或任何其他编译语言一样。 This ar
如何在每次通话时打印列表或 haskell 中的内容,例如: funct a list = funct (a + 1) (a : list) print list her
让我用我对 Makefiles 或 make 知之甚少的评论作为这个问题的前缀。 有一个非常大的项目,每晚自动构建。它以 Debug 和 Release 模式构建,Debug 用于 Valgrind
我正在创建一个计算每周工资的程序,那么任何加类工资都是该周正常工资的 1.5 倍。我的代码如下: #include int main() { double payrate; double h
我使用的是 Visual Studio 2010 Express Developer 版本。开发网站。我在我的 .aspx 页面中使用 JavaScript。 如何在 Javascript 中放置断点
我最近开始修补 Project Euler 问题,并尝试用 Javascript 解决它们。这样做我往往会产生许多无限循环,现在我想知道是否有比终止 Firefox 或 Chrome 中的选项卡更好的
有没有办法在程序执行期间生成一个交互式 python 控制台(最好是 iPython)而不暂停主程序并且能够检查和修改程序变量?类似于浏览器为 JavaScript 提供的功能。 我知道 pdb.se
我正在使用 FFmpeg @ Android 并希望能够进入 FFmpeg 代码(Eclipse + Seqouya),同时编译 FFmpeg 我使用 --disable-stripping --en
我从使用互操作调用 win32 api 函数的 .net 进程中得到一个异常。 我有一个调试器,我想查看 LastError 的值。 是否可以从 Visual Studio 调试器中查看 LastEr
我正在尝试通过 VBA 创建一个宏,以在 IE 的多个选项卡中打开一组指定的链接。目前我正在使用下面的代码,如果我试图打开 3 个或更少的选项卡,它大部分时间都可以工作。任何超过 3 的代码都会在“N
好的,这似乎是一个愚蠢的问题,因为 MonoDevelop 越来越成熟,所以我确定我只是想念它,但我环顾四周,所有关于这个主题的问题似乎都是关于远程调试或 Mac 上的调试。 我使用的是 Ubuntu
如何调试 Rscripts是从命令行运行的? 我目前正在使用 getopt传递命令行选项的包,当有错误时,我很难: 看看到底出了什么问题; 在 R 中交互式调试(因为脚本需要命令行选项。) 有没有人有
支持 PDF 和网络上的信息很少。我碰巧在博客中看到一篇文章,提到 $.write() 或 $.writeln() 将向 javascript 控制台写入一个字符串。相当有用。有谁知道这个 $ 对象是
PyCharm 1.5 中是否可以使用 Firefox 和 Chrome 支持的 JavaScript 调试? 如果是这样,它能否与 Python/Django 调试器一起有效运行? 如果没有,有没有
我确定这以前发生在人们身上,某些东西在 Debug模式下工作,你在发布时编译,但有些东西坏了。 这发生在我在嵌入式 XP 环境中工作时,我发现最好的方法确实是编写一个日志文件来确定它会出错的地方。 您
我目前正在为即将到来的项目评估 Flow3。 AOP 模式和依赖注入(inject)将非常适合我们的目的。 现在我想不通的是如何在 Controller Action 中调试一些结果。 public
最初,我有一个包含测试服务器的 Django 应用程序。要调试此设置,我只需添加 import pdb; pdb.set_trace()代码中的任何位置,并且有一个断点将我扔到终端中的交互式调试器中(
我是一名优秀的程序员,十分优秀!