|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
原代码:
- import os.path
- def GDOS():
- while True:
- inp = str(input('请输入指令:'))
- if inp[:8] == 'G_print:':
- content = inp[8:]
- print(content)
- elif inp == 'G_quit':
- print('退出登录!')
- break
- elif inp == 'Nfile':
- fileName = str(input('新创建文件的文件名(需要写后缀):'))
- filePath = str(input('新创建文件的路径:'))
- openFilePath = filePath + fileName
- temp = open(openFilePath,'w')
- writeStr = str(input('要写入文件的内容:'))
- temp.write(writeStr)
- temp.close
- elif inp == 'Wfile':
- fileName = str(input('要打开文件的文件名:'))
- filePath = str(input('要打开文件的路径:'))
- openFilePath = filePath + fileName
- temp = open(openFilePath,'a')
- writeStr = str(input('要写入文件的内容:'))
- temp.write(writeStr)
- temp.close
- elif inp[:5] == 'help:':
- if inp[5:] == 'GDOS_encoding':
- print('光电OSpyhon_cmd版默认采用cp936的文件编码格式')
- elif inp == 'Nfile_pro':
- print('由于此功能过于灵活,可能会报错,不要惊慌,那是因为编码格式不存在导致的,不会危害电脑。')
- fileName = str(input('新创建文件的文件名(需要写后缀):'))
- filePath = str(input('新创建文件的路径:'))
- fileCoding = str(input('新创建文件的文件编码格式'))
- openFilePath = filePath + fileName
- temp = open(openFilePath,'w',encoding = fileCoding )
- writeStr = str(input('要写入文件的内容:'))
- temp.write(writeStr)
- temp.close
- def new():
- name = str(input('请输入用户名:'))
- if name in user:
- print('已存在用户名为' + name + '的用户!')
- else:
- code = str(input('请输入密码:'))
- user[name] = code
- print('注册成功!')
- def loin():
- name_search = str(input('请输入用户名:'))
- if name_search in user:
- code_search = str(input('请输入密码:'))
- if code_search == user[name_search]:
- print('登录成功!')
- print('欢迎进入GD_cmd系统!')
- GDOS()
- else:
- print('密码输入错误!')
- else:
- print('您输入的用户不存在!')
- print('请登录GD OS的账户以使用GD OS的所有功能')
- print('|---新建用户: N/n----|')
- print('|---登录账号: E/e----|')
- print('|---关闭系统: Q/q----|')
- if os.path.exists('C:\\gdcmd\\gdcmduser.txt') == True:
- temp = open('C:\\gdcmd\\gdcmduser.txt','w')
- temp1 = temp.read()
- user = temp1
- else:
- user = {}
- while True:
- instructions = str(input('请输入指令代码:'))
- if instructions == 'N' or instructions == 'n':
- new()
- elif instructions == 'E' or instructions == 'e':
- loin()
- elif instructions == 'Q' or instructions == 'q':
- print('关闭系统!')
- if os.path.exsits('C:\\gdcmd') == True:
- temp = open('C:\\gdcmd\\gdcmduser.txt','w')
- temp.write(user)
- temp.close
- else:
- os.path.mkdir('C:\\gdcmd')
- temp = open('C:\\gdcmd\\gdcmduser.txt','w')
- temp.write(user)
- temp.close
- break
- else:
- print('该指令不存在!')
复制代码 报错信息:- <blockquote>Traceback (most recent call last):
复制代码 请问为什么它说没有exists方法? |
|