python - open () function to open and read the file

Note: Windows slash file system path as '\' 
open () call to open the file path function
calls to read and write function writes data

1, tutorial example:

 

 

 

 

 2, actual examples:

 

 

 Operating results as follows:

 

3, summary

→ python with a backslash '\' escape character, so the error in the case of '\' is used as an escape, leading to interpretation errors interprets the file path.

There are two ways to write → path:

    First, the '\' direction reverse to '/', i.e. the first correct the text written;

    Second, before the string is added containing escapes 'r' represents the original string in their meanings, not escape processing. (recommend!)

 

 

 

 

Guess you like

Origin www.cnblogs.com/xzxgiser/p/12535580.html