티스토리 뷰
Python3 의 실행방법에는 전체 Source Code를 Text 파일로 저장하여 Python 인터프리터을 통해 실행하는 Script 실행파일 방식과
짧은 구문 테스트등을 위해 대화형 인터프리터를 실행하여 인터프리터 프롬프트 라인에 코드를 입력하여 테스트하는 방식으로 나뉜다.
1. Python3 대화형 인터프리터 실행 방법 및 예시
[root@centos7 python3]# [root@centos7 python3]# which python /root/python3/anaconda3/bin/python [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# which python3 /root/python3/anaconda3/bin/python3 [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# python Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:53:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# python3 Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:53:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> print("Hi~ Python3") Hi~ Python3 >>> >>> >>> >>> license() A. HISTORY OF THE SOFTWARE ========================== Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands as a successor of a language called ABC. Guido remains Python's principal author, although it includes many contributions from others. In 1995, Guido continued his work on Python at the Corporation for National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) in Reston, Virginia where he released several versions of the software. In May 2000, Guido and the Python core development team moved to BeOpen.com to form the BeOpen PythonLabs team. In October of the same year, the PythonLabs team moved to Digital Creations (now Zope Corporation, see http://www.zope.com). In 2001, the Python Software Foundation (PSF, see http://www.python.org/psf/) was formed, a non-profit organization created specifically to own Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF. All Python releases are Open Source (see http://www.opensource.org for Hit Return for more, or q (and Return) to quit: q >>> >>> >>> exit() [root@centos7 python3]# [root@centos7 python3]# |
2. Python3 Script 파일 실행 예시
[root@centos7 python3]# [root@centos7 python3]# vi ./hello.py print("hello pyton") [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# python ./hello.py hello pyton [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# |
3. Python3 대화형 인터프리터의 다양한 실행 예시
[root@centos7 python3]# [root@centos7 python3]# python Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 2 2016, 17:53:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>> 1.1 * 1.5 1.6500000000000001 >>> >>> >>> -1 * 1 -1 >>> >>> -5 * 15 -75 >>> >>> 7.5 * 2.5 18.75 >>> >>> >>> ex1 = 7.5 * 2.5 >>> >>> ex1 18.75 >>> >>> print(ex1) 18.75 >>> >>> >>> ex1 * 100 1875.0 >>> >>> >>> exit() [root@centos7 python3]# [root@centos7 python3]# [root@centos7 python3]# |
'System Story > Python3' 카테고리의 다른 글
Python3 연산 및 특징 (0) | 2016.11.29 |
---|---|
CentOS 7 Python3 및 Anaconda 표준 Library 설치 (2) | 2016.11.25 |