1. 程式人生 > 實用技巧 >SymGAN—Exploiting Images for Video Recognition: Heterogeneous Feature Augmentation via Symmetric Adversarial Learning學習筆記

SymGAN—Exploiting Images for Video Recognition: Heterogeneous Feature Augmentation via Symmetric Adversarial Learning學習筆記

import pickle
import os
class User:
def init(self,name,id,tel,card):
self.name = name
self.id = id
self.tel = tel
self.card = card
@staticmethod
def xieru(x):
path =os.path.join(os.getcwd(),'a.db')
f = open(path,'wb')
pickle.dump(x,f)
f.close()
@staticmethod
def duqu():
path = os.path.join(os.getcwd(),'a.db')
f = open(path,'rb')
a = pickle.load(f)
f.close()
return a
class Admin:
def init

(self,name,passwd):
self.name = name
self.passwd = passwd

def login(self):
    for i in range(3):
        name = input('輸入管理員賬號:')
        passwd = input('輸入管理員密碼:')
        if name == self.name and passwd == self.passwd :
            print('登陸成功!')
            return True
        else:
            print('登入失敗!')

class Card:
def init(self,num,money,pwd):
self.num = num
self.money = money
self.pwd = pwd
self.clock = False

from user import User
from card import Card
from admin import Admin
import random

class Atm:
def init(self):
self.user_dict = {}

def welcome(self):
    print('*' * 30)
    print('*' + " " * 6 + '開戶(1)' + '  ' + '查詢(2)' + ' ' * 6 + '*')
    print("*" + " " * 6 + '取款(3)' + '  ' + '存款(4)' + ' ' * 6 + '*')
    print("*" + " " * 6 + '轉賬(5)' + '  ' + '改密(6)' + ' ' * 6 + '*')
    print("*" + " " * 6 + '鎖定(7)' + '  ' + '解鎖(8)' + ' ' * 6 + '*')
    print("*" + " " * 6 + '銷戶(9)' + '  ' + '退出(0)' + ' ' * 6 + '*')
    print('*' * 30)
def mkcard(self):
    cardid = ''
    for i in range(6):
        a = str(random.randint(0,9))
        cardid += a
    return cardid

if name == 'main':

atm = Atm()
admin = Admin('admin','123456')


if admin.login():
    try:
        atm.user_dict = User.duqu()
    except Exception as e:
        print(' ')
    while True:
        atm.welcome()
        print(atm.user_dict)
        choice = int(input('請輸入想要執行的操作:'))
        if choice == 1:
            name = input('輸入姓名:')
            cid = input('身份證號:')
            tel = input('手機號:')
            pwd1 = input('輸入密碼:')
            pwd2 = input('再次確認密碼:')
            if pwd1 == pwd2 :
                num = atm.mkcard()
                money = int(input('請輸入開戶金額(>=10$):'))
                if money < 10 :
                    print('金額太少,開戶失敗')
                    continue
                card = Card(num,money,pwd2)
                user = User(name,cid,tel,card)
                atm.user_dict[num] = user
                # User.xieru(fdy.user_dict)
                print('開戶成功,您的卡號為:%s 卡上餘額%.2f:'%(num,money))
            else:
                print('密碼不一致,開戶失敗')


        elif choice == 2:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                if user.card.clock == False:
                    for i in range(3):
                        pwd = input('請輸入密碼:')
                        if pwd == user.card.pwd:
                            print('卡號:%s 姓名:%s 手機號:%s 餘額:%.2f¥'%
                                  (num,user.name,user.tel,user.card.money))
                            break
                        else:
                            print('密碼錯誤!')
                    else:
                        print('密碼錯誤三次,卡已被鎖!')
                        user.card.clock = True

                        # '''此處切記要將字典資訊再儲存一遍'''
                        # User.xieru(fdy.user_dict)
                else:
                    print('此卡已鎖,請先解鎖!')
            else:
                print('卡號不存在!')
        elif choice == 3:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                if user.card.clock == False:
                    for i in range(3):
                        pwd = input('請輸入密碼:')
                        if pwd == user.card.pwd:
                            qumoney = int(input('請輸入取款金額:'))
                            if qumoney <= user.card.money:
                                user.card.money-=qumoney
                                # User.xieru(fdy.user_dict)
                                print('取款成功!卡上餘額:%.2f¥'%(user.card.money))
                                break
                            else:
                                print('餘額不足!')
                                break
                        else:
                            print('密碼錯誤!')
                    else:
                        print('密碼錯誤三次,卡已被鎖!')
                        user.card.clock = True
                        # User.xieru(fdy.user_dict)
                else:
                    print('此卡已鎖,請先解鎖!')
            else:
                print('卡號不存在!')
        elif choice == 4:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                if user.card.clock == False:
                    for i in range(3):
                        pwd = input('請輸入密碼:')
                        if pwd == user.card.pwd:
                            qumoney = float(input('請輸入存款金額:'))
                            user.card.money += qumoney
                            # User.xieru(fdy.user_dict)
                            print('存款成功!卡上餘額:%.2f¥'%(user.card.money))
                            break
                        else:
                            print('密碼錯誤!')
                    else:
                        print('密碼錯誤三次,卡已被鎖!')
                        user.card.clock = True
                        # User.xieru(fdy.user_dict)
                else:
                    print('此卡已鎖,請先解鎖!')
            else:
                print('卡號不存在!')
        elif choice == 5:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                if user.card.clock == False:
                    for i in range(3):
                        pwd = input('請輸入密碼:')
                        if pwd == user.card.pwd:
                            qumoney = float(input('請輸入轉賬金額:'))
                            num1 = input('請輸入對方卡號:')
                            if num1 in atm.user_dict:
                                user1 = atm.user_dict.get(num1)
                                if qumoney <= user.card.money:
                                    print('y:確認轉賬 n:取消轉賬')
                                    answer = input('')
                                    if answer == 'y':
                                        user.card.money-=qumoney
                                        user1.card.money+=qumoney
                                        # User.xieru(fdy.user_dict)
                                        print('轉賬成功!卡上餘額:%.2f¥'%(user.card.money))
                                        break
                                    elif answer == 'n':
                                        print('已取消轉賬!')
                                        break
                                else:
                                    print('金額不足!')
                                    break
                            else:
                                print('對方卡號不存在!')
                                break
                        else:
                            print('密碼錯誤!')
                    else:
                        print('密碼錯誤三次,卡已被鎖!')
                        user.card.clock = True
                        # User.xieru(fdy.user_dict)
                else:
                    print('此卡已鎖,請先解鎖!')
            else:
                print('卡號不存在!')
        elif choice == 6:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                if user.card.clock == False:
                    for i in range(3):
                        pwd = input('請輸入密碼:')
                        if pwd == user.card.pwd:
                            pwd1 = input('請輸入新的密碼:')
                            pwd2 = input('請再次輸入新的密碼:')
                            if pwd1 == pwd2 :
                                user.card.pwd = pwd2
                                # User.xieru(fdy.user_dict)
                                print('密碼修改成功!')
                                break
                        else:
                            print('密碼錯誤!')

                    else:
                        print('密碼錯誤三次,卡已被鎖!')
                        user.card.clock = True
                        # User.xieru(fdy.user_dict)
                else:
                    print('此卡已鎖,請先解鎖!')
            else:
                print('卡號不存在!')
        elif choice == 7:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                pwd = input('請輸入密碼:')
                if pwd == user.card.pwd:
                    user.card.clock = True
                    # User.xieru(fdy.user_dict)
                    print('卡已鎖!')
                else:
                    print('密碼錯誤!')
            else:
                print('卡號無效!')
        elif choice == 8:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                pwd = input('請輸入密碼:')
                if pwd == user.card.pwd:
                    user.card.clock = False
                    # User.xieru(fdy.user_dict)
                    print('卡已解鎖!')
                else:
                    print('密碼錯誤!')
            else:
                print('卡號無效!')
        elif choice == 9:
            num = input('請輸入卡號:')
            if num in atm.user_dict:
                user = atm.user_dict.get(num)
                if user.card.clock == False:
                    for i in range(3):
                        pwd = input('請輸入密碼:')
                        if pwd == user.card.pwd:
                            print('確定要銷戶嗎?')
                            answer = input('y/n:')
                            if answer == 'y':
                                atm.user_dict.pop(num)
                                print('銷戶成功!')
                                User.xieru(atm.user_dict)
                                break
                            else:
                                print('已取消操作!')
                                break
                        else:
                            print('密碼錯誤!')
                    else:
                        print('密碼錯誤三次,卡已被鎖!')
                        user.card.clock = True
                        # User.xieru(fdy.user_dict)
                else:
                    print('此卡已鎖,請先解鎖!')
            else:
                print('卡號不存在!')
        elif choice == 0:
            #程式正常退出儲存資料(非正常退出則無法儲存)
            User.xieru(atm.user_dict)
            break

開戶

查詢

取款

存款

改密

銷戶

psp2.1 任務內容 計劃完成需要的時間(min) 實際完成需要的時間(min)
Planning 計劃 10 9
Estimate 估計這個任務需要多少時間,並規劃大致工作步驟 10 7
Development 開發 140 120
Analysis 需求分析 12 5
Design Spec 生成設計文件 5 5
Design Review 設計複審 5 5
Coding Standard 程式碼規範 3 2
Design 具體設計 10 12
Coding 具體編碼 36 21
Code Review 程式碼複審 5 7
Test 測試 10 15
Reporting 報告 9 6
Test Report 測試報告 3 2
Size Measurement 計算工作量 2 1
Postmortem & Process Improvement Plan 事後總結 3 3