Three forms the basis function defined functions movement of the cursor in the document

Open with # (r'a.txt ',' R & lt ', encoding =' UTF-. 8 ') AS F: 
# = DATAl reached, f.read ()
# Print ('>. 1>: ', DATAl)
# Print (F .tell ()) # 44 is only one case, the character cursor mean
# DATA2 reached, f.read = ()
# Print ( '> 2>:', DATA2) # result of the first time, the second is not, after the first reading the data at the cursor has been moved to the end of the file

# only one case, the cursor is in units of characters: rt opened file, read ()
# with open (r'a.txt ',' rt ', = encoding 'UTF-. 8') aS F:
# Print (reached, f.read (. 8))
# Print (f.tell ())
# f.seek (0,0) Seek bytes #
# print (f. Read (. 8))
# Print (f.tell ())
# f.seek (13 is, 0)
# Print (reached, f.read (. 3))
# Print (f.tell ())

# 0 mode is possible only mode t using the
# with open (r'a.txt ',' rt ', encoding =' utf-8 ') as f:
# print(f.read(3))
# f.seek(3,3)
Print # (reached, f.read (. 3))

# with Open (r'a.txt ',' RB ') AS F:
# Print (reached, f.read (. 6)) # b'hello \ XE4'
# f.seek ( 2,1)
# Print (f.tell ())
. Print # (reached, f.read () decode ( 'UTF_8'))

# with Open (r'a.txt ',' RB ') AS F:
# F. seek (-3,2) # 3 moves the cursor backwards
# Print (f.tell ())
# f.seek (0,2) to move the cursor directly to the end of the #

# tail -f access.log # open the file, read additional content

# Import Time
# with Open (r'b.txt ',' RB ') AS F:
# f.seek (0,2) to the end of the cursor #
# the while True:
# = f.readline Line ( ) carrying all the data types # Boolean, once the blank is False
# IF Line:
# Print (Line, End = '')
# the else:
# the time.sleep (0.05)

Open with # (r'b.txt ',' A ', encoding =' UTF-. 8 ') AS F:
# f.write (' are you My Apple \ n-')
# f.flush () and write append # immediately save to your hard drive

# Import Time
# with Open (r'b.txt ',' rb ') AS f:
# f.seek (0,2)
# the while True:
# f.readline Line = ()
# IF Line:
# print (line) # 'end =' '' bytes type without any line mean, end = '' is a normal string
# the else:
# the time.sleep (0.05)

# Import Time
# with Open (r'b. TXT ',' RB ') AS F:
# f.seek (0,2)
# the while True:
# = f.readline Line ()
# IF Line:
# Print (line.decode (), End =' ')
# else:
The time.sleep # (0.05)

# file truncation
Open with # (r'a.txt ',' A ', encoding =' UTF-. 8 ') AS F:
# f.truncate (. 3) to retain only the first three bytes #

# Why should function? There is no function to bring trouble
# organizational structure is not clear, poor readability
# code redundancy
# poor scalability
# What is the function?
# Includes a single function tool
called after # define
# Function Category
# built-in functions: len (), max (10,100),
# custom function: DEF
# custom function:
# DEF function (parameter 1, parameter 2, ...): # parameters can not write, but () have a
# (indentation) '' 'Notes' '' # help (function name) comments must have, but still optional
# # function body must have
Alternatively the return value # return #
# ===============
# Apple by You are My
# ===============

# DEF print_tag ():
Print # ( '===============')
# DEF print_msg ():
# Print ( 'Apple by You are My')

# Print (print_tag) # <function print_tag at 0x00000178BEC54DC8> memory address
# = equivalent print_tag <function print_tag AT 0x00000178BEC54DC8>

# print_tag ()
# print_msg ()
# print_tag ()
# '' '
# ======== =======
# Apple by You are My
# ===============
# '' '
# DEF print_tag ():
# Print (' * '* 15)
# DEF print_msg ():
# Print ( 'Apple by You are My')
# print_tag ()
# print_msg ()
# print_tag ()
# '' '
# ***************
# Apple by You are My
*************** #
# '' '# high scalability

# DEF the auth ():
# name = INPUT (' >> name: ').strip()
# password=input('password>>:').strip()
IF name == # 'OBOS' and password == '123':
# Print ( 'successful landing')
# the else:
# Print ( 'user name or password is incorrect')
#
# auth ()

#-defined functions have taken place in stages what's up?
#-Defined functions only detect syntax stage, does not execute code. Grammar no problem on the definition of success, does not complain.

After the first call using #
# DEF foo ():
# Print ( 'from foo')
# bar ()
# DEF bar ():
# Print ( 'bar from')

three forms defined function #
# The first: None function parameter #
# DEF foo ():
# DEF bar ():
# DEF print_tag ():
# DEF print_msg ():
# X = 10
# Y =. 11
# IF X> = Y:
# Print ( 'X')
# the else:
# Print ( 'Y')
# The second: YES function parameter
# my_max DEF (X, Y):
# IF X> = Y:

The else #:
# Print (Y)
# my_max (1,2)
# DEF the auth (name, password):
# IF name == 'OBOS' and password == '123':
# Print ( 'successful login')
# the else :
# Print ( 'user name or password is incorrect')
#
# DEF Love ():
# the INPUT name = ( 'name >>:') Strip ().
# password = the INPUT ( 'password >>:') Strip (. )
# the auth (name, password)
# Love ()
# function as each doing, a function to extract individual
# third: empty function
# DEF the auth ():
# '' '
#' ''
# Pass
# DEF PUT ():
# Pass
# DEF GET ():
# Pass
# DEF iS ():
# Pass
the organizational structure of the program reflects #

Guess you like

Origin www.cnblogs.com/0B0S/p/11952840.html