__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)
-
The latent SVM tells the learning method used in this paper -> "Discriminatively trained deformable part models". The authors s...
-
In past, I wrote an articel about YUV 444, 422, 411 introduction and yuv rgb converting example code. refer to this page -> http://feel...
-
My Environment : MS VS 2008 & MFC(Dialog Based) Joy Stick : Logitech Extreme 3D pro (XBox Type) Cteated Date : 2012. 03 [source code]...
-
refer to code: .. import torch # create a tensor x = torch . randn ( 3 , 4 ) # set print options to display full tensor torch . set_print...
-
Creating a custom CUDA kernel that directly utilizes tensor cores is an advanced topic, as tensor cores are typically accessed through highe...
-
Created Date : 2011.10 Language : C/C++ Tool : Microsoft Visual C++ 2008 Library & Utilized : OpenCV 2.3 Reference : SIFT referenc...
-
KEY KeyCode ASCII KEY KeyCode ASCII 0 48 48 Numpad 0 96 48 1 49 49 Numpad 1 97 49 2 50 50 Num...
-
yolo v5 data coordinate format ex) str_v = "32 0.262 0.7878 0.314 0.385" #read image cvmat = cv2.imread(img_path) #get height, w...
-
Example 1: Basic Variadic Template # include <iostream> // 1. Simple function that accepts any number of arguments template ...
-
Optical Flow sample source code using OpenCV. It programed based on http://feelmare.blogspot.kr/2012/10/make-2-frame-having-time-interv...
No comments:
Post a Comment