def _main_(userInput1):
if userInput1 ==create:
userName1=input('Please enter your username : ')
password1=input('Please enter your password : ')
createAccount(userName1, password1)
else:
userName2=input('Please enter your username : ')
password2=input('Please enter your password : ')
logIn(userName2,password2)
userInput1=input('Would you like to create a account or long in, type create or login ')
_main_(userInput1)
我一直收到错误:
'create'未定义
有人可以帮忙吗?
答案 0 :(得分:2)
如果您要检查func applicationDidFinishLaunching(_ aNotification: Notification) {
NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(updateClock), userInfo: nil, repeats: true)
}
func updateClock() {
let date = NSDate()
let calendar = NSCalendar.current
let components = calendar.dateComponents([.second],from:date as Date) as NSDateComponents
if components.second == 0 || components.second == 30 {
makeStatusMenu()
}
}
func makeStatusMenu() {
}
是否等于字符串userInput1
,则需要将create
放在引号中,如下所示:create
或此{{1} }}。否则,Python会检查'create'
是否等于变量 "create"
。
答案 1 :(得分:1)
您需要将userInput1
更改为create
,因为当您询问用户是否要创建用户时,输入默认为字符串,因此您需要引号以告知编译器识别它是一个字符串,而不是将if userInput1 == create
视为变量。