Home > other >  The use of the python print
The use of the python print

Time:11-26

Don't know why the result of the fifth line output TXT and the fourth row, is printed in the fourth and the fifth row, only in front of the can complete printing

CodePudding user response:

Four five lines are just two kinds of format string syntax, the fourth line is relatively common, the fifth line is later new syntax
Print it at the same time, the first printed out, file read pointer has moved to the final, so print is empty again
Can the fourth row behind add a
 f_name. Seek (0) 
try

CodePudding user response:

Thank you, I try, the fifth line grammar don't understand, more to see

CodePudding user response:

Thank you, I try, the fifth line grammar don't understand, more to see

CodePudding user response:

The fifth line of code is a string formatting

Like % s

Here just use is {}, then add f in front of the string, and then want to pass parameters in curly braces

 
A='hello'
B=f '{a} world! '
Print (b)

Output # # # # # # # # # #
hello world!


In addition to know the format string formatting methods that may be more easy to understand

CodePudding user response:

This starts a new string formatting python3.6 way f - string.
The inside of the curly braces is replaceable

CodePudding user response:

Thanks, I don't know
  • Related