程序如下:
#/usr/bin/python
#-*-coding:utf-8-*-
db={}
def newuser():
while Ture:
nname=raw_input("请输入新用户名:")
if db.has_key(nname):
pirnt "用户名以创建!"
continue
else:
break
while Ture:
pwd=raw_input("请输入密码:")
pwd1=raw_input("再输入一次密码:")
if pwd==pwd1:
db[nname]=pwd
break
else:
continue
def old():
while Ture:
oname=raw_input("请输入用户名:")
if db.has_key(oname):
passwd=raw_input("请输入密码:")
while Ture:
if passwd==db.get(oname):
print("欢迎进入!")
break
else:
print("密码错误!")
continue
break
else:
continue
def menu():
print'''1.登录
2.新建用户
3.退出'''
op=raw_input("输入选项:")
if op==1:
a=newuser()
elif op==2:
a=old()
else op==3:
print "欢迎使用"
menu()
运行时总显示:
./11.py: 行 4: 未预期的符号 `(' 附近有语法错误
./11.py: 行 4: `def newuser():'
wskssau@wskssau-Aspire-4750:~/pro/python/prom/a$ ./11.py
./11.py: 行 5: 未预期的符号 `(' 附近有语法错误
./11.py: 行 5: `def old():'
编辑器是kate,版本是2.7
wei2012dt 于 2012-06-01 08:54:23发表:
It was really about the "True"(o):tx
wei2012dt 于 2012-06-01 08:42:03发表:
Ture or True?