__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...
-
As you can see in the following video, I created a class that stitching n cameras in real time. https://www.youtube.com/user/feelmare/sear...
-
fig 1. Left: set 4 points (Left Top, Right Top, Right Bottom, Left Bottom), right:warped image to (0,0) (300,0), (300,300), (0,300) Fi...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
Created Date : 2011.10 Language : C/C++ Tool : Microsoft Visual C++ 2008 Library & Utilized : OpenCV 2.3 Reference : SIFT referenc...
-
In the YUV color format, Y is bright information, U is blue color area, V is red color area. Show the below picture. The picture is u-v col...
-
OpenCV has AdaBoost algorithm function. And gpu version also is provided. For using detection, we prepare the trained xml file. Although...
-
I once wrote the following article. http://study.marearts.com/2014/04/opencv-study-mat-point-access-method.html This article is a sample c...
-
Created Date : 2011.8 Language : Matlab Tool : Matlab 2010 Library & Utilized : - Reference : Multiple View Geometry (Hartly and Z...
No comments:
Post a Comment