在我开始之前,还有许多其他确切的问题,但是没有一个答案足以解决我的问题。类/函数log.info('foo')运行一次,没有问题,但是第二次调用它得到了错误TypeError: 'str' object is not callable
我发现这个问题与我有相同的问题,但是我没有任何东西叫做str。我已经使用其他功能(例如战争)进行了测试。
我的代码:
import praw
import sys
import traceback
from accounts import *
class logging:
def info(self, log):
self.info = '\033[94m'
self.rs = '\033[0m'
print self.info, 'INFO: ', self.rs
def warn(self, log):
self.warn = '\033[93m'
self.rs = '\033[0m'
print self.warn, 'WARNING: ', self.log, self.rs
def critical(self, log):
self.critical = '\033[91m'
self.rs = '\033[0m'
print self.critical, 'CRITICAL: ', log, self.rs
def read_accounts():
with open('accounts.py') as f:
for i, l in enumerate(f): …Run Code Online (Sandbox Code Playgroud)