我开始学习Python,但我的代码有问题,希望有人能帮忙。我有两个函数,我想从一个函数中调用另一个函数。当我尝试调用函数时,它似乎被忽略了,所以我猜测问题出在我如何调用它上面。下面是我代码的片段。
# 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()函数,它就在代码片段下面。 :)
&
和|
吗? - Ignacio Vazquez-Abrams