下面這段程式中, 我預期會得到目前的日期加上字串In prtn_global_config.
可是執行後出現TypeError: prtn_global_config() missing 1 required positional argument: 'self'
error highlight處在最後一行prtn_global_config()
請教問題是出在哪裡呢? 謝謝.
PS. 我使用Sublime, python 3.6.8
import logging
import sys
import random
import time
import datetime
def prtn_info(self, msg):
print(str(datetime.datetime.now()) + msg) #datetime.datetime.now():獲取當前datetime
def prtn_global_config(self):
self.prtn_info('In prtn_global_config')
prtn_global_config()