如何清除.py中的屏幕变成.exe?

时间:2015-01-26 18:12:48

标签: python screen clear

我正在学习Python,我已经完成了我的第一个程序,并且已经使用py2exe将其转换为.exe。

程序完成后,系统会询问您是否再次运行程序或退出程序。问题是,如果我再次运行程序,我可以看到我之前做过的事情。相反,我想要删除之前所做的所有操作并将其运行,就好像这是第一次。我真的很感激。

以下是代码:

def main():
    days = input("Write how many days you will be on vacation: ")
    city = input("Write the city in which you will be staying at: ")
    expenses = input("Write how much money you will be carrying for expenses (US$): ")

    def hotelCost(days):
        days = int(days)
        return 140*days

    hotelCost(days)

    def flightCost(city):
        if city == "Charlotte" or city == "charlotte":
            return 183
        elif city == "Tempa" or city == "tempa":
            return 220
        elif city == "Pittsburgh" or city == "pittsburgh":
            return 222
        elif city == "Los Angeles" or city == "los angeles":
            return 475
        else:
            print ("Invalid destination")

    flightCost(city)

    def carCost(days):
        days = int(days)
        cost = days*40
        if days >= 7:
            cost -= 50
        elif days >= 3:
            cost -= 20
        return cost

    carCost(days)

    def totalCost():
        overallCost = hotelCost(days) + flightCost(city) + carCost(days)
        overallCost = str(overallCost)
        print ("\nThe total cost of your trip is $" + overallCost)

    totalCost()

    def again():
        yesNo = input("\nWould you like to calculate the cost of another trip? (y/n)\n")

        if yesNo == "y":            
            print ("\n")
            main()

    again()

main()

0 个答案:

没有答案