__author__ = 'mare' import os print( os.getcwd() ) #/Users/mare/PycharmProjects/OS_module print( os.access('.', os.F_OK ) ) print( os.access('.', os.W_OK | os.X_OK | os.R_OK ) ) #write, exec, read #True #True os.rmdir('test1') print( os.listdir('.') ) #['.idea', 'osModule.py'] os.mkdir('test1') print( os.listdir('.' ) ) #['.idea', 'osModule.py', 'test1'] os.removedirs('test2/sub1/sub2/leaf') os.makedirs('test2/sub1/sub2/leaf') print( os.listdir('test2/sub1/sub2') ) #['leaf'] print(os.listdir('.')) os.rename('newfile.txt', 'oldfile.txt') print(os.listdir('.')) #['.idea', 'newfile.txt', 'osModule.py', 'test1', 'test2'] #['.idea', 'oldfile.txt', 'osModule.py', 'test1', 'test2'] os.rename('oldfile.txt','newfile.txt') os.renames('newfile.txt', 'ttt/moved.txt') print( os.listdir('ttt') ) #['.DS_Store', 'moved.txt'] os.renames('ttt/moved.txt', 'newfile.txt') print( os.stat('newfile.txt') ) #posix.stat_result(st_mode=33188, st_ino=5325009, st_dev=16777219, st_nlink=1, st_uid=501, st_gid=20, st_size=0, st_atime=1394464185, st_mtime=1394463961, st_ctime=1394463961) #I made directory like that # - test_walk # +- a # +- b # +- newfile.txt for path, dirs, files in os.walk('test_walk'): print( path, dirs, files) #test_walk ['a', 'b'] ['.DS_Store'] #test_walk/a [] [] #test_walk/b [] ['newfile.txt'] for path, dirs, files in os.walk('test_walk', topdown=False): print( path, dirs, files) #test_walk/a [] [] #test_walk/b [] ['newfile.txt'] #test_walk ['a', 'b'] ['.DS_Store'] print( os.pipe() ) #create pipe to communicate between proccess #file object creation #r, w = os.pipe() #rd = os.fdopen(r) #rp = os.popen('dir' 'r') #print( p.read() ) print(os.name) #posix print( os.environ ) #environ({'__CF_USER_TEXT_ENCODING': '0x1F5:3:51', 'SSH_AUTH_SOCK': '/tmp/launch-XLOLCi/Listeners', 'PYCHARM_HOSTED': '1', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'PYTHONIOENCODING': 'UTF-8', 'PYTHONUNBUFFERED': '1', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', 'LOGNAME': 'mare', 'USER': 'mare', 'HOME': '/Users/mare', 'TMPDIR': '/var/folders/b7/gxpfjkqs0bs33cyyn76q7drw0000gn/T/', 'VERSIONER_PYTHON_VERSION': '2.7', '__CHECKFIX1436934': '1', 'Apple_PubSub_Socket_Render': '/tmp/launch-bHTzXo/Render', 'SHELL': '/bin/bash', '__PYVENV_LAUNCHER__': '/Library/Frameworks/Python.framework/Versions/3.3/bin/python3', 'PYTHONPATH': '/Users/mare/PycharmProjects/OS_module'}) print( os.environ.keys() ) #KeysView(environ({'__CF_USER_TEXT_ENCODING': '0x1F5:3:51', 'SSH_AUTH_SOCK': '/tmp/launch-XLOLCi/Listeners', 'PYTHONPATH': '/Users/mare/PycharmProjects/OS_module', 'LOGNAME': 'mare', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', 'PYCHARM_HOSTED': '1', '__CHECKFIX1436934': '1', 'PYTHONUNBUFFERED': '1', 'SHELL': '/bin/bash', 'Apple_PubSub_Socket_Render': '/tmp/launch-bHTzXo/Render', 'PYTHONIOENCODING': 'UTF-8', 'TMPDIR': '/var/folders/b7/gxpfjkqs0bs33cyyn76q7drw0000gn/T/', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'USER': 'mare', 'VERSIONER_PYTHON_VERSION': '2.7', '__PYVENV_LAUNCHER__': '/Library/Frameworks/Python.framework/Versions/3.3/bin/python3', 'HOME': '/Users/mare'})) print( os.getpid() ) #10140 os.system('calc') #os.startfile('LICENSE.txt')
3/10/2014
Python study, OS modules
Subscribe to:
Post Comments (Atom)
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
//Singular value decomposition : Mat w, u, v; SVDecomp(data, w, u, v); // A = U W V^T //The flags cause U and V to be returned transpose...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv rgb converting example code. refer to this page -> http://feel...
-
dp parameter is about resolution of voting space. dp is larger, voting resolution is small compare to image size. so dp is larger, circle...
-
Optical Flow sample source code using OpenCV. It programed based on http://feelmare.blogspot.kr/2012/10/make-2-frame-having-time-interv...
-
line, circle, rectangle, ellipse, polyline, fillConvexPoly, putText, drawContours example source code!!. ... //http://study....
-
What is TorchOps.cpp.inc ? TorchOps.cpp.inc : This file contains implementations of the operations for the torch-mlir dialect. It is ty...
-
recent EEG datasets and papers from the last 5 years: OpenNeuro EEG Datasets (2020-Present) DS003190: High-density EEG during motor tasks (...
-
I can know all coordinate from A point to B point using "LineIterator" function in OpenCV. So this source code is applied by this...
-
TensorFlow install using virtualenv on ubuntu environment. The method is same with pip install. http://study.marearts.com/2016/04/tensorf...
No comments:
Post a Comment