Working with Directories,workingdirectories,# The os.pat
文章由Byrx.net分享于2019-03-23 06:03:56
Working with Directories,workingdirectories,# The os.pat
# The os.path module has several functions for manipulating files and directories. # Here, we'll look at handling pathnames and listing the contents of a directory. import os print os.path.join('c:\\yourfolder\\', 'yourfile.txt')print os.path.join('c:\\yourfolder', 'yourfile.txt') os.path.expanduser('~') print os.path.join(os.path.expanduser('~'), 'Python')# os.path is a reference to a module-which module depends on your platform. Just # as getpass encapsulates differences between platforms by setting getpass to a # platform-specific function, os encapsulates differences between platforms by # setting path to a platform-specific module.
相关内容
- Working with File Objects,workingobjects,# Python has
- File Random Access,filerandomaccess,f = open(r'c
- Adding Line Numbers to a Python Script,addingpython,import filei
- Writes the contents of string to the file,writescontents,f = open('
- Zip file,zipfile,import zipfi
- Demonstrates reading from a text file,,# print 'Ope
- Reading characters from the file.,readingcharacters,print '\nRea
- Reading characters from a line.,readingcharacters,print '\nRea
- Print out a date, given year, month, and day as numbers,givennumber
- Define and ouuput string: 8-bit, 1-byte, 2-byte and 4-byte,ouuput1-
评论关闭