티스토리 뷰
-. argv
Python 스크립트로 넘어온 입력인자들의 리스트
0번째는 스크립트의 이름이며, 그 이후부터 인자가 설정됨
import sys
for i,t in enumerate(sys.argv):
print(i,t)
실행
[root@localhost systest]# python systest.py arg1 arg2 arg3
(0, 'systest.py')
(1, 'arg1')
(2, 'arg2')
(3, 'arg3')
-. exc_info()
현재 발생한 예외정보를 튜플로 반환 #예외가 없는 경우 None을 반환
>>> sys.exc_info()
(None, None, None)
import sys
try:
1/0
except:
(ec,ev,tb) = sys.exc_info()
print(ec)
print(ev)
print(tb)
실행
#unix system(python2.4)
exceptions.ZeroDivisionError
integer division or modulo by zero
<traceback object at 0x2afbe8b0ae60>
#window(python3.2)
<class 'ZeroDivisionError'>
division by zero
<traceback object at 0x00FEC850>
-. prefix, exec_prefix, executable
Python이 설치된 경로와 실행파일을 나타냄
>>> sys.prefix #Python이 설치된 경로
'C:\\Python32'
>>> sys.exec_prefix #Python이 설치된 경로
'C:\\Python32'
>>> sys.executable #파이썬 인터프리터의 실행파일 경로
'C:\\Python32\\pythonw.exe'
-. exit([arg])
프로세스 종료
arg가 0인 경우 정상종료 0이 아닌경우 비정상종료로 처리됨
>>> sys.exit(0)
-. getrefcount(object)
객체의 참조 카운트값을 반환
>>> t = "test"
>>> sys.getrefcount(t)
16
>>> t1 = t
>>> sys.getrefcount(t)
17
-. getwindowsversion ()
현재 윈도우의 버전을 튜플로 반환
>>> sys.getwindowsversion()
sys.getwindowsversion(major=5, minor=1, build=2600, platform=2, service_pack='Service Pack 3')
-. modules
현재 로딩되어 있는 모듈들을 사전 형태로 나타냅니다.
>>> sys.modules
{'heapq': <module 'heapq' from 'C:\Python32\lib\heapq.py'>, 'tkinter.filedialog': <module 'tkinter.filedialog' from 'C:\Python32\lib\tkinter\filedialog.py'>, 'functools': <module 'functools' from 'C:\Python32\lib\functools.py'>, 'random': <module 'random' from 'C:\Python32\lib\random.py'>, '_bisect': <module '_bisect' (built-in)>, 'sysconfig': <module 'sysconfig' from 'C:\Python32\lib\sysconfig.py'>, 'idlelib.macosxSupport': <module 'idlelib.macosxSupport' from 'C:\Python32\lib\idlelib\macosxSupport.py'>, 'ctypes._endian': <module 'ctypes._endian' from 'C:\Python32\lib\ctypes\_endian.py'>, 'builtins': <module 'builtins' (built-in)>, 'struct': <module 'struct' from 'C:\Python32\lib\struct.py'>, 'tempfile': <module 'tempfile' from 'C:\Pytho.........
-. path
모듈을 찾을때 참조하는 경로를 나타냄
>>> sys.path
['C:\\Python32\\Lib\\idlelib', 'C:\\Python32', 'D:\\Cloude\\Python\\lib2', 'C:\\WINDOWS\\system32\\python32.zip', 'C:\\Python32\\DLLs', 'C:\\Python32\\lib', 'C:\\Python32\\lib\\site-packages']
-. copyright, version
설치된 파이썬의 저작권, 버전을 나타냄
>>> sys.copyright
'Copyright (c) 2001-2011 Python Software Foundation.\nAll Rights Reserved.\n\nCopyright (c) 2000 BeOpen.com.\nAll Rights Reserved.\n\nCopyright (c) 1995-2001 Corporation for National Research Initiatives.\nAll Rights Reserved.\n\nCopyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\nAll Rights Reserved.'
>>> sys.version
'3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)]'
-. getdefaultencoding()
현재 사용중인 기본 문자열 인코딩을 반환함
>>> sys.getdefaultencoding()
'utf-8'
-. stdin, stdout, stderr
표준 입력,출력, 에러스트림에 대응되는 파일 객체들을 나타냄
>>> sys.stdin
<idlelib.rpc.RPCProxy object at 0x00F3A2D0>
>>> sys.stdout
<idlelib.rpc.RPCProxy object at 0x00F41C70>
>>> sys.stderr
<idlelib.rpc.RPCProxy object at 0x00F41C90>
'Python' 카테고리의 다른 글
Python, 2.x와 3의 차이 (0) | 2016.04.21 |
---|---|
Python, 2와 3의 차이 (0) | 2016.04.21 |
Python,module os [운영체제] (0) | 2016.04.21 |
Python, Class (0) | 2016.04.21 |
Python, join (0) | 2016.04.21 |
- Total
- Today
- Yesterday
- tkinter command & bind [명령어묶기와 사건묶기] Python
- 폼
- 파이썬
- FetchType
- borderwidth
- ManyToOne
- activebackground
- Linux
- highlightbackground
- JPA
- tkinter
- Java
- Excel
- disabledforeground
- highlightthickness
- vba
- 리눅스
- Module
- IdClass
- 상수
- Python
- command
- fetch join
- onetomany
- checkbutton
- Composite Key
- Private
- activeforeground
- indicatoron
- apache
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |