Python 解释器
生活随笔
收集整理的這篇文章主要介紹了
Python 解释器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Python 解釋器
關于python 環境 這里不再介紹,可參考以下介紹:
Mac Anaconda 簡單介紹 -- 環境管理
交互式編程
我們可以在命令提示符中輸入"python"命令來啟動Python解釋器:
(Adil) yangyaojundeMacBook-Pro:PyWeb yyj$ python Python 3.7.1 (default, Oct 23 2018, 14:07:42) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>>在 python 提示符中輸入以下語句,然后按回車鍵查看運行效果:
print ("Hello, Python!");?
以上命令執行結果如下:
Hello, Python!?
腳本式編程
新建 test.py文件
# FileName : test.py # Author : Adil # DateTime : 2019/1/22 4:04 PM # SoftWare : PyCharmprint('hello python !')?
通過以下命令執行該腳本:
?
python test.py輸出結果為:
(Adil) yangyaojundeMacBook-Pro:PyWeb yyj$ python test.py hello python !在Linux/Unix系統中,你可以在腳本頂部添加以下命令讓Python腳本可以像SHELL腳本一樣可直接執行:
#! /Users/yyj/anaconda3/envs/Adil/bin/python修改后如下:
#! /Users/yyj/anaconda3/envs/Adil/bin/python # 以上為python 環境變量,通過 which python 獲取# FileName : test.py # Author : Adil # DateTime : 2019/1/22 4:04 PM # SoftWare : PyCharmprint('hello python !')然后修改腳本權限,使其有執行權限,命令如下:
$ chmod +x test.py?
執行以下命令:
./test.py輸出結果為:
(Adil) yangyaojundeMacBook-Pro:PyWeb yyj$ ./test.py hello python !?
轉載于:https://www.cnblogs.com/BlueSkyyj/p/10304614.html
總結
以上是生活随笔為你收集整理的Python 解释器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: bboss官网
- 下一篇: websocket python爬虫_p