Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x tracer.run(';main()';)报告名称错误_Python 3.x - Fatal编程技术网

Python 3.x tracer.run(';main()';)报告名称错误

Python 3.x tracer.run(';main()';)报告名称错误,python-3.x,Python 3.x,我正在阅读并得到了一个关于 import sys import trace # create a Trace object, telling it what to ignore, and whether to # do tracing or line-counting or both. tracer = trace.Trace( ignoredirs=[sys.prefix, sys.exec_prefix], trace=0, count=1) # run the

我正在阅读并得到了一个关于

import sys
import trace

# create a Trace object, telling it what to ignore, and whether to
# do tracing or line-counting or both.
tracer = trace.Trace(
    ignoredirs=[sys.prefix, sys.exec_prefix],
    trace=0,
    count=1)

# run the new command using the given tracer
tracer.run('main()')

# make a report, placing output in the current directory
r = tracer.results()
r.write_results(show_missing=True, coverdir=".")
运行它并获取错误信息

 NameError: name 'main' is not defined

这样一个愚蠢的虚拟示例的目的是什么?

您需要一个名为main的函数才能使示例工作。在本例中,您正在跟踪函数main()的执行情况,因此需要显示函数main()才能成功运行本例

您是否创建了
main()
function?ty。明白了,但又臭又有趣的例子。