在鳕鱼里什么也不干

2024-06-16 09:53:19 发布

您现在位置:Python中文网/ 问答频道 /正文

Possible Duplicate:
Python Application does nothing

#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("HOSTNAME")
        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()

input()应该执行,它在更改了我不记得的内容后停止工作

它是在python3.1.2和windows7下编写的,我知道Unix Hostname全局变量是错误的

我知道userinput什么都不做,我想在继续之前让这部分工作

谢谢

它什么也不输出


Tags: importhomedatetimeosdefusernameshellgetenv