使用Python trace()跟踪乘法表
我感兴趣的是了解如何实现Python的跟踪模块,以跟踪乘法表的执行并打印其带注释的结果 我研究了与trace()和乘法程序相关的Python文档和internet源代码,但结果一无所获使用Python trace()跟踪乘法表,python,trace,multiplication,execution,Python,Trace,Multiplication,Execution,我感兴趣的是了解如何实现Python的跟踪模块,以跟踪乘法表的执行并打印其带注释的结果 我研究了与trace()和乘法程序相关的Python文档和internet源代码,但结果一无所获 import sys import trace tracer = trace.Trace( ignoredirs=[sys.prefix, sys.exec_prefix], trace=0, count=1) def print_multiples(n, high): for
import sys
import trace
tracer = trace.Trace(
ignoredirs=[sys.prefix, sys.exec_prefix],
trace=0,
count=1)
def print_multiples(n, high):
for i in range(1, high+1):
print(n * i, end=" ")
print()
def print_mult_table(high):
""" Return a multiplication table with n rows and columns."""
for i in range(1, high+1):
print_multiples(i, high)
print_mult_table(7)
r = tracer.results()
r.write_results(show_missing=True, coverdir=".")
同样,我想弄清楚如何实现Python的跟踪模块,以跟踪乘法表的执行并打印带注释的结果