Os module using the time and Python module total amount of non-used []

Time Import 
print ( 'current timestamp:% F' the time.time% ())
the time.sleep (. 3) continue # suspended three seconds
t = time.localtime (1574949906) # conversion timestamp, time out is structured
print (time.strftime ( '% Y-% m- % d% H-% M-% S', t)) # structured time into a string of time


Import OS
Print (the os.getcwd ()) # Get the current working path
# hereinafter, referring to the directory folder
back one level the os.chdir ( '..') #
Print (the os.getcwd ())
# os.makdirs ( 'Zhai / Hui / LAN') to establish a recursive # Catalog
# os.chdir ( 'zhai') # change the current working directory, can only go to the next directory
# Print (os.getcwd ())
# os.mkdir ( 'under zhai') # create a single catalog
# os .chdir ( 'under zhai')
# Print (os.getcwd ())
# os.rmdir ( 'zhai') # delete a single empty folder, you must delete subdirectories in the parent directory to operate, and must be empty to delete
# os.removedirs ( 'zhai / hui / lan') # delete recursive directory also must remove the child to the parent, and must be empty
print (os.listdir (os.getcwd ()) ) # list all files in the specified directory, including hidden files, print out a list of the form
# os.remove ( 'zhai / hui / lan / aaa.txt') # delete files in the specified path, only to start writing a relative path from the current path, or an absolute path
# os.rename ( 'zhai', ' wulanzi') # rename a directory or file can be
# print (os.listdir (os. getcwd ()))
# print (the os.stat ( '0604 / ternary operator .py')) # out of structured information, commonly used c creation time, last modification time m, a last checked
print (os.sep) # print out the current operating system path separator
print (os.linesep) # print out the current operating system line terminator, win is \ r \ n, Linux is \ n-
Print (os.pathsep) # printing the character string for dividing a file path, win for the next; as the Linux:
Print (the os.path.split (the os.getcwd ())) # the path and file divided into two parts, the output :( 'C: zHLAN the Users \\ \\ Desktop \\ ',' zhlan-code ')
Print the first part (os.path.dirname (os.getcwd ())) # output divided
print (os.path.basename (os.getcwd ())) # output Cutting a second portion of the
print (os.path.isdir ( '0604') ) # determines whether the current directory to the directory exists, returns a Boolean value
print (os.path.isfile ( 'aaa') ) # determine whether there is a current path to the file, returns a Boolean value
# stitching path, not the real, pure human splice it
a = 'D: \ python- zhlan'
b = '1130 \ my file'
Print (the os.path.join (a, B))
# returns the last modified time, or the current path of the file, the time stamp is converted to a structured, which is then converted to a string time
= time.localtime TTM (os.path.getmtime (The os.getcwd ()))
Print (The time.strftime ( '%% Y-H-M-% D%%% M-S', TTM))









Guess you like

Origin www.cnblogs.com/zhlan/p/11961896.html