當前位置: 首頁>>代碼示例>>Python>>正文


Python Data.new方法代碼示例

本文整理匯總了Python中Data.new方法的典型用法代碼示例。如果您正苦於以下問題:Python Data.new方法的具體用法?Python Data.new怎麽用?Python Data.new使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Data的用法示例。


在下文中一共展示了Data.new方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import Data [as 別名]
# 或者: from Data import new [as 別名]
 def main(self):
     print
     print("Romulus10's Quick Checkbook Register")
     print
     done = False
     while not done:
         print(self.account_name)
         self.total = self.fin.get_total(self.transactions)
         if self.total is None:
             print("$0")
         else:
             print('$' + str(self.total))
         cmd = raw_input('> ')
         cmd = cmd.split(' ')
         while len(cmd) < 4:
             cmd.append('')
         if cmd[0] == "quit":
             done = True
         if cmd[0] == "help":
             print(self.help)
         if cmd[0] == "new":
             if cmd[1] != '':
                 self.transactions = Data.new(cmd[1])
                 self.account_name = cmd[1]
         if cmd[0] == "load":
             if cmd[1] != '':
                 self.transactions = Data.load(cmd[1])["transactions"]
                 self.categories = Data.load(cmd[1])["categories"]
                 self.amounts = Data.load(cmd[1])["category_amounts"]
                 self.account_name = cmd[1]
         if cmd[0] == "save":
             Data.save(self.account_name, self.transactions)
         if cmd[0] == "copy":
             Data.copy(cmd[1], cmd[2])
         if cmd[0] == "add":
             if cmd[1] != '' and cmd[2] != '' and cmd[3] != '':
                 self.add(cmd)
         if cmd[0] == "delete":
             if cmd[1] != '':
                 x = None
                 for y in self.transactions:
                     if y.number == int(cmd[1]):
                         x = y
                 self.transactions.remove(x)
         if cmd[0] == "print":
             t = PrettyTable(["Number", "Name", "Category", "Date", "Amount"])
             for x in self.transactions:
                 t.add_row([x.number, x.name, x.category, x.date, ('$' + str(x.value))])
             print(t)
         if cmd[0] == "categories":
             t = PrettyTable(["Name", "Current Value"])
             for i in range(len(self.categories)):
                 t.add_row([str(self.categories[i]), ('$' + str(self.amounts[i]))])
             print(t)
         if cmd[0] == "gui":
             gui = TKBook()
             gui.root.mainloop()
         print
     print
開發者ID:Romulus10,項目名稱:Python-Workspace,代碼行數:61,代碼來源:checkbook.py

示例2: close_new

# 需要導入模塊: import Data [as 別名]
# 或者: from Data import new [as 別名]
 def close_new(self, y):
     """
     Create a new account with name y.
     :param y: string
     """
     self.transaction_list = Data.new(str(y))
     self.labels = []
     self.account_name = str(y)
     self.total = 0
     self.s.set(self.account_name)
     self.t.set("$" + str(self.total))
     self.new_window.destroy()
     for x in self.labels:
         x.destroy()
開發者ID:Romulus10,項目名稱:Python-Workspace,代碼行數:16,代碼來源:startGUI.py


注:本文中的Data.new方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。