python函数未返回所需字符串

python函数未返回所需字符串,python,Python,我有一个程序,可以扫描输入文本,寻找命令。命令使用大写字母并由符号包围 这个程序的一部分包括一个功能,可以提前扫描下一个命令 def nextCommand(command): lar = command.find("<LAR>") #...etc (stripped out variable defs used in statements below) if lar != -1 and lar > sma or lar > med or lar

我有一个程序,可以扫描输入文本,寻找命令。命令使用大写字母并由符号包围

这个程序的一部分包括一个功能,可以提前扫描下一个命令

def nextCommand(command):
    lar = command.find("<LAR>")
    #...etc (stripped out variable defs used in statements below)
    if lar != -1 and lar > sma or lar > med or lar > bar or lar > fba or lar > fee or lar > lef or lar > rig or lar > cen or lar > end:
        print "nextCommand - lar:" + str(lar)
        return str("<LAR>")
    if sma != -1 and sma > lar or sma > med or sma > bar or sma > fba or sma > fee or sma > lef or sma > rig or sma > cen or sma > end:
        print "nextCommandsma:" + str(sma)
        return str("<SMA>")
        #stripped out more checks
    else:
        return str("")
如果我输入 123 SMA 456 LAR 789 而不是看到SM>我看到:(取出<符号,因为s/o认为这是攻击的一部分) “从nextCommand()接收的值为:

功能下一个命令位于

我做错了什么?

您实际上已经打印了函数的表示形式。请注意:

nextCommand # This references the function
以及:


我想你是想把
next\u命令放在这里,而不是
nextCommand

print "value recieved from nextCommand() is: " + str(nextCommand)
应该是:

print "value recieved from nextCommand() is: " + next_command

您实际上已经打印了函数的表示形式。请注意:

nextCommand # This references the function
以及:


我想你是想把
next\u命令放在这里,而不是
nextCommand

print "value recieved from nextCommand() is: " + str(nextCommand)
应该是:

print "value recieved from nextCommand() is: " + next_command

为什么
str(“”
“”
已经是一个字符串。它最初不是一个字符串,但在尝试调试它时嗅探了错误的树为什么
str(“”
““
已经是字符串。它最初不是字符串,但在尝试调试时嗅探错误的树it@ICTTeacher不客气:)。别忘了:)@ICT老师不客气:)。别忘了:)