在我更改了我不再记得的内容后,这段代码根本停止执行任何操作
#Dash Shell
import os
import datetime
class LocalComputer:
pass
def InitInformation():
Home = LocalComputer()
#Acquires user information
if (os.name == "nt"):
Home.ComputerName = os.getenv("COMPUTERNAME")
Home.Username = os.getenv("USERNAME")
Home.Homedir = os.getenv("HOMEPATH")
else:
Home.ComputerName = os.getenv()
Home.Username = os.getenv("USER")
Home.Homedir = os.getenv("HOME")
return Home
def MainShellLoop():
print ("--- Dash Shell ---")
Home = InitInformation()
userinput = None
currentdir = Home.Homedir
while (userinput != "exit"):
rightnow = datetime.datetime.now()
try:
userinput = input(str(Home.ComputerName) + "\\" + str(Home.Username) + ":" + str(rightnow.month) + "/" + str(rightnow.day) + "/" + str(rightnow.year) + "@" + str(currentdir))
except:
print("Invalid Command specified, please try again")
MainShellLoop()
编辑:哈哈,对不起,大家忘了说它应该运行输入
你应该更好地描述你的问题。是否打印输入提示?它输出什么吗?它会退出还是只是坐在那里?我在阅读这段代码时注意到一些可能有帮助的问题。您应该使用 raw_input(),而不是 input()。另外,除非用户输入==“退出”,否则您实际上不会对用户输入执行任何操作。这是不会的,因为您只是使用 input(),而不是 raw_input(),因此该人必须输入“exit”(包括引号),否则循环将永远不会退出。 (假设它不是Python 3代码)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)