Jar*_*ner 0 python function syntax-error
我刚刚开始学习python ...所以请耐心等待
为什么这个代码块给我一个无效的语法错误
def InvalidArgsSpecified:
print ("*** Simtho Usage ***\n")
print ("-i Installs Local App,, include full path")
print ("-u Uninstalls Installed App,include ID or Name")
print ("-li Lists all installed Apps and their ID")
print ("-all Lists All Apps in Repository")
print ("-di Downloads and Installs App from repository, enter the title or id number")
print ("-dw Downloads and Installs Single App from a full link")
print ("-rmall Removes All Packages installed and removes Simtho itself\n")
print ("*** End of Simtho Usage ***")
sys.exit()
Run Code Online (Sandbox Code Playgroud)
编辑:现在它说第9行第9行未定义了
InvalidArgsSpecified()
Run Code Online (Sandbox Code Playgroud)
语法错误位于第一行,您可以在其中:
def InvalidArgsSpecified:
Run Code Online (Sandbox Code Playgroud)
将其更改为:
def InvalidArgsSpecified():
Run Code Online (Sandbox Code Playgroud)
这些括号在a中是强制性的def,即使它们之间没有任何东西(就像括号总是用于调用函数一样 - 空括号,在这种情况下,如果你在没有参数的情况下调用).
编辑:现在OP在第9行尝试调用此函数时出错:由于此函数定义超过9行,因此在定义之前可能会调用它(从模块顶层而不是从另一个函数中调用),在这种情况下,简单的解决方法是仅在定义之后调用它.如果它比这更微妙,我们需要看到代码来为你调试它! - )