Built-in functions: role of input and output, input, print and \ r of

input:

INPUT = NAME1 ( ' Enter your name: " ) # input character string passed NAME1 
Print (NAME1) # prints the input character string

print:

DEF  Print (Self, * args, On Sep = '  ' , End = ' \ n- ' , File = None): # Known Special Case of Print 
    "" " 
    Print (value, ..., On Sep = '', End = ' \ n-', file = sys.stdout, the flush = False) 
    file: default output to the screen, if the settings as a file handle to a file 
    sep: separator between the plurality of print values, default blank 
    end: each the end of the print, the default is a newline 
    flush: immediately output to stream content file, without caching 
    "" "

 

print a variety of built-in methods:

  file: The output of the contents of the screen, output to a file

Import OS 
F = Open ( ' name ' , ' A + ' , encoding = ' UTF-. 8 ' ) 
name = INPUT ( ' Enter your name: ' )
 Print (name + ' \ n- ' , File = F) # The print output to file 
f.close ()

  sep: separator between the plurality of print values, the default is a space

  end: after the end of each print, the default is newline

print(1,2,3,sep='-')#1-2-3

for i in range(5):
    print(i,end=' ')#0 1 2 3 4
    print(i)

 

 

\ R Role: The position of the cursor back to the beginning of this article, with the end to achieve not repeat print, print only one row of effects

Import Time
 for I in Range (10 ):
     Print ( ' \ R & lt exit from the second left {} ' .format (. 9-I), End = '' ) 
    the time.sleep ( . 1)

 

Guess you like

Origin www.cnblogs.com/aizhinong/p/11404620.html