Splitting Pathnames,splittingpathnames,import os os
Splitting Pathnames,splittingpathnames,import os os
import os os.path.split('c:\\music\\ap\\m.mp3') (filepath, filename) = os.path.split('c:\\music\\ap\\m.mp3') print filepath print filename (shortname, extension) = os.path.splitext(filename) print shortname print extension # The split function splits a full pathname and returns a tuple containing the path # and filename. # os.path also contains a function splitext, which splits a filename and returns a # tuple containing the filename and the file extension.
- Define and use Modules,definemodules,# Fibonacci
- Get the length: number of items inside a string,length
- Formatted print: float,formattedfloat,print '%.2f'
- String indexing: Random Access,indexingrandom,import r
- Change CRLF line endings to LF (Windows to Unix),crlfe
- Logging: log messages are sent to a file or to sys.stder
热门文章:
相关内容
- Define and use Modules,definemodules,# Fibonacci
- Get the length: number of items inside a string,lengthitems,print l
- Formatted print: float,formattedfloat,print '%.2f'
- String indexing: Random Access,indexingrandom,import rando
- Change CRLF line endings to LF (Windows to Unix),crlfendings,'''PYT
- Logging: log messages are sent to a file or to sys.stderr,loggingsy
- Functional Programming Tools: reduce,,# 'reduce(fu
- Function call,functioncall,print pow(2,
- Strings are printed without quotes, and a space is inserted inbetween,
- List concatenation: speed,concatenationspeed,L = [1, 2]L
评论关闭