小编san*_*san的帖子

TypeError: debug() 缺少 1 个必需的位置参数:从不同类调用方法时“msg”

请指出我做错了什么,我是编码新手。

1.第一个.py文件:

import logging
class Log:
    def __init__(self,msg):
        self.msg = msg

    def debug(self,msg):
        FORMAT  = "%(asctime)-15s%(message)s"
        logging.basicConfig(filemode = "w", filename="file.log", format = FORMAT, level=logging.DEBUG)
        logging.debug(self.msg)
Run Code Online (Sandbox Code Playgroud)

2.第二个.py文件

import first
first.Log.debug("I am in debug mode")
Run Code Online (Sandbox Code Playgroud)

当我运行 secondary.py 文件时,我收到错误 Logging.Log.debug("I am in debug mode")

TypeError: debug() missing 1 required positional argument: 'msg'** 
Run Code Online (Sandbox Code Playgroud)

python

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×1