本文整理汇总了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
示例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()