出于调试目的,我发现如果我可以打印局部范围内的变量并且只打印本地范围内的变量,那将是有益的。
样品:
def showAuthUser(self):
"""Make a request to the campfire server.
Returns a getPage object which is deferred.
"""
u = self.uri + self._resource['showAuthUser']
m = 'GET'
n = self.username
p = self.password
b = base64.encodestring('{0}:{1}'.format(n, p))
h = {'Authorization': 'Basic ' + b.strip()}
return self._getPage(u, m, h)
有没有办法在h?
之后找到局部范围内所有变量的值答案 0 :(得分:6)
您可以使用locals()
功能