---restore content starts---
Can you call it a function?
Open () function
How to open a file
Handle=open (file_name,access_mode= ' R ')
R Read
W Write
A add
+ Read/write
b binary Access
The default access_mode is R, read-only
If Open () succeeds, a file object handle is returned, and all subsequent file operations must be done through this file handle. When a file object is returned, we can access some of its methods, such as ReadLines () and close (). The method properties of a file object must also be accessed through the period property identifier.
Core notes: What are attributes, properties are data-related items, properties can be simple data values, or they can be execution objects such as functions and methods, and which objects have properties? Many objects, such as classes, modules, files, and complex numbers, have properties, how do we Access object properties? Use the period attribute to identify the method, which means to add a period (.) between the object name and the property name:
Object.attribute. Chinese Translation Objects-Properties
FileName =raw_input (' Enter file name ')
Fobj=open (filename, ' R ')
For Eachline in Fobj:
Print Eachline, #注意, this place has a comma, so there's no line break, but he automatically adds spaces.
Fobj.close ()
Files and built-in functions open () file ()