In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge points about the attributes of files and file objects in Python, which are detailed in content and clear in logic. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
1 file
''
file store
The file master name. Extension name
''
The common data file types in Python are text files, binary files and CSV files.
The text file is encoded by ASCII, and the man stores the internal code.
Binaries are files encoded with variable length based on values, which cannot be viewed directly by a text compiler.
Comma separated value (csv) files, preferably with a text compiler
2 File object
The backslash in a string is an escape character, so you can represent the path of a string in two special ways.
Precede the string with r
Hierarchical relationships in path strings are represented by double backslashes
Os.getcwd: returns the current work path as a string
Os.chdir (path): modifies the current work path to the work path specified by path
Os.listdir (path): get all the files and folders under the work path specified by path
Common properties of file objects:
Name: indicates the file name that contains the path
Close: indicates the status of the file. Turn it off to True and open to False.
Mode: indicates the file open mode
File object open mode:
R: indicates read-only mode
W: indicates write-only mode
A: indicates the append mode
B: represents binary mode and can be combined with (can be used in combination with r, w, a modes)
T: indicates the text mode, which can be omitted
+: indicates read-write mode
These are all the contents of this article entitled "what are the attributes of files and file objects in Python?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.