Python の学習を始めていますが、コードに問題があり、誰かが助けてくれることを望んでいました。2 つの関数があり、1 つの関数を別の関数から呼び出したいと考えています。単純に関数を呼び出そうとしたところ、無視されたように見えたので、呼び出し方の問題だと思います。以下は、問題の私のコードのスニペットです。
# Define the raw message function
def raw(msg):
s.send(msg+'\r\n')
# This is the part where I try to call the output function, but it
# does not seem to work.
output('msg', '[==>] '+msg)
return
# Define the output and error function
def output(type, msg):
if ((type == 'msg') & (debug == 1)) | (type != msg):
print('['+strftime("%H:%M:%S", gmtime())+'] ['+type.upper()+'] '+msg)
if type.lower() == 'fatal':
sys.exit()
return
# I will still need to call the output() function from outside a
# function as well. When I specified a static method for output(),
# calling output() outside a function (like below) didn't seem to work.
output('notice', 'Script started')
raw("NICK :PythonBot")
編集しました。私は実際に raw() 関数を呼び出していますが、それはスニペットのすぐ下にありました。:)