导入模块时出现Python 2.7语法错误

时间:2020-05-06 14:21:48

标签: python debugging syntax-error spyder

首先感谢您阅读此问题。

我正在尝试将模块导入到新脚本中。

我正在使用以下命令:

import mosaic.qdfTrajIO as qdf 

这将返回以下语法错误:

runfile('C:/Users/reneb/projects/mosaic/mosaic/utilities/mosaicLogging.py',
wdir='C:/Users/reneb/projects/mosaic/mosaic/utilities')


File "C:/Users/reneb/projects/mosaic/mosaic/utilities/mosaicLogging.py", line 50
class mosaicLogging(object, metaclass=metaSingleton):
                                     ^

SyntaxError:语法无效

这是第42至59行的代码:

class MessageFormatter(logging.Formatter):
def format(self, record):
    try:
        record.msg = record.msg.strip()
    except:
        pass
    return super(MessageFormatter, self).format(record)

class mosaicLogging(object, metaclass=metaSingleton): #this is where the error takes place

"""A custom logging class that uses the Python logging facility. Logs are automatically saved to a metaMDIO instance,
    and to a file log when DeveloperMode is active.
"""

_loggers = {}

log=logging.getLogger()
log.setLevel(logging.DEBUG)

0 个答案:

没有答案