Python Day14 jobs

os Import 
Import Time

#
# 1, write function ,, incoming user to modify the file name, and you want to modify the content, perform functions, approved a modification to complete the operation
# DEF the Revise (path, TXT, r_txt):
# with Open (path , 'R & lt +') AS F:
# reached, f.read RES = ()
# = C_RES res.replace (TXT, r_txt)
# f.seek (0)
# Print (C_RES)
# f.write (C_RES)
#
#
# path = input ( 'enter path')
# TXT = input ( 'enter your changes')
# r_txt = input ( 'enter your changes after')
# the Revise (path, TXT, r_txt)
# 2, write function, calculate the incoming character string [digital], [letter], [space] and [other] number

# txt = input ( 'enter the string')
#
#
# DEF COUNT (TXT):
# n_n = 0
# = 0 S_N
# Z_n 0 =
# = 0 A_N
# for i in TXT:
I.isdigit IF # ():
# = n_n. 1 +
# elif I == '':
# = + S_N. 1
# elif i.isalpha ():
# = Z_n. 1 +
# the else:
# = A_N +. 1
# Print ( f 'digits {n_n}, other number {a_n}, the number of spaces {s_n}, the number of letters Z_n} {')
#
#
# COUNT (TXT)

#. 3, the write function, the user determines the object passed if (strings, lists, tuples) length is greater than 5.
#
# DEF Decide (TXT):
# IF len (TXT)>. 5:
# Print ( 'greater than. 5')
# the else:
# Print ( 'less than. 5')
#
#
# TXT = (. 1, 23 is,. 4,. 5, 6, 7)
# Decide (TXT)
# 4, write function to check incoming length of the list, if more than 2, then only preserve the contents of the first two lengths, and returns the new content to the caller.
#
# DEF Change (List):
Len IF # (List)> 2:
# c_list = [X IF list.index List for X in (X) <2]
# the else:
# Print ( 'length is less than 2')
# return c_list
#
#
# List = [. 1 , 23 is, 45,. 5]
# = c_list Change (list)
# Print (c_list)

#. 5, the write function to check an overview of all odd bit index or list of elements corresponding incoming tuple object, and returns it as a new list to the caller.
#
# DEF FUNC (Content):
# n_content = [! IF X for X in content.index Content (X)% 2 = 0]
# return n_content
#
#
# Print (FUNC (Content = [1,23,4,5 6]))
# 6, write functions, each the length of a value check dictionary, if greater than 2, then retaining only the content length of the first two, and returns the new content to the caller.
= {DIC "K1": "v1v1", "K2": [. 11, 22 is, 33 is, 44 is]}


# the PS: is the only value in the dictionary string or list
# DEF FUNC (DIC):
# for I in dic:
# value = dic[i]
# if len(value) > 2 and type(value) == list:
# n_value = [x for x in value if value.index(x) < 2]
# dic[i] = n_value
# if len(value) > 2 and type(value) == str:
# n_value=value[0:2]
# dic[i] = n_value
#
# return dic
#
#
# print(func(dic))
# 选做作业:同昨天
# def login():
# print('开始登录')
# login_t = False
# tag = False
# count = 0
# while count < 3:
# in_name = input('输入名字:')
# in_password = input('请输入密码:')
Open with # ( 'db.txt', encoding = 'UTF-. 8') AS F, Open ( '. Db.txt.swap', MODE = 'W',) AS F1:
# for I in F:
# name , password, Money, Lock i.strip = ( '\ n-') Split ( ':').
# == IF in_name name:
# = True Tag
# Print ( 'user exists,', End = '')
# IF lock == == in_password and password 'lock_on':
# Print ( 'account is locked, unable to land')
# COUNT = 3
# elif password == in_password and lock = 'lock_on':!
# Print ( 'Login successful')
# count = 3
# login_t = True
In_name atm_name = #
# the else:
# Print ( 'wrong password three times will be locked')
# = 1 + COUNT
# COUNT IF == 3:
# Print ( 'three errors is locked')
# = Lock 'lock_on'
# F = I '{name}: {password}: {} Money: Lock} {\ n-'
# f1.write (I)
# the else:
# Tag not IF:
# Print ( 'user does not exist')
# The os.remove ( 'db.txt')
# os.rename ( '. db.txt.swap', 'db.txt')
# login_t return,atm_name
#
#
# # 4, written registration function
# def register ():
# Print ( 'registration')
# = in_name the INPUT ( 'Enter the name:')
# in_password the INPUT = ( 'Please enter your password:')
# with Open ( 'db.txt', the MODE = 'A', encoding = 'UTF -8 ') AS F1, Open (r'db.txt', encoding = 'UTF-. 8') AS F2:
# for I in F2:
. # A = i.strip ( '\ n-') Split ( ': ')
# in_name IF A == [0]:
# Print (' registered ')
# BREAK
# the else:
# f1.write (F' {} in_name: {} in_password: 0: lock_off \ n-')
# Print ( 'successful registration')
#
#
# DEF OUT ():
#, Ltd. Free Join Tag
# Tag = False
#
#
# DEF ATM (the User):
# atm_f = {
# 1: take_money,
# 2: invest_money,
# 3: remove_money,
# 4: show_money
#}
# info = "" "
# withdrawals. 1
# 2 charge money
# 3 money transfer
# 4 balance inquiry
#" ""
# Print (info)
# chose = input ( 'input selection:')
# IF int (chose) in atm_f:
# atm_f.get (int (chose)) (User)
# the else:
# Print ( 'input is not the right choice')
#
#
# DEF change_dbm ( User, c_money):
# with Open ( 'db.txt', MODE = 'R & lt', encoding = 'UTF-. 8') AS F, \
# Open ( '. db.txt.swap', MODE = 'W' ) AS F2:
# for I in F:
# A = i.strip ( '\ n-').split(':')
# name, password, money, lock = a
# if user == name:
# money = int(money)
# money = money + int(c_money)
# i = f'{name}:{password}:{money}:{lock}\n'
# f2.write(i)
# os.remove('db.txt')
# os.rename('.db.txt.swap', 'db.txt')
# return money
#
#
# def take_money(user):
# c_money = input('输入要取的钱')
# money = -int(c_money)
# change_dbm(user, money)
#
#
# def invest_money(user):
# c_money = input('输入要存入的钱')
# change_dbm(user, c_money)
#
#
# def remove_money(user):
# Pass
#
#
# DEF show_money (User):
# Print (change_dbm (User))
#
#
# #. 5, writing user authentication function
# RES = {
# OUT: 0,
# Login:. 1,
# Register: 2
#}
# True = Tag
# the while Tag:
# msg = "" "
# 0 exit
# 1 Login
# 2 registration
#" ""
# Print (msg)
# cmd = the iNPUT ( 'enter the command number >>:') .strip ()
for i in RES #:
# IF str (res.get (i)) == cmd:
# info = i ()
# if_login, the User = info
# IF if_login:
# ATM (the User)

# Optional problem: write a program ATM achieve a function, a file data from db.txt
# 1, top-up: the user to enter an amount of money prepaid, db.txt amount of money in the account to complete the modification
# 2, the transfer function: the user A to the user B transfers 1000 yuan, db.txt completed Save money account of the user A, user B account to add money to
# 3, cash functions: user input withdrawal amount, the account number the money db.txt reduction
# 4, balance inquiry function: enter the account balance inquiries

# Optional problem of Optional problem: Log feature
# user logs in successfully after recording memory in this state, the above functions to whichever state currently logged in, you must be logged in to operation
#

Guess you like

Origin www.cnblogs.com/AaronY/p/12518895.html