在Ubuntu中安裝Python后,可通過以下方式測試其功能:
python3 --version
,顯示版本號即安裝成功。python3
,進入交互模式,輸入代碼(如 print("Hello")
)并查看即時結果。hello.py
文件,寫入 print("Hello, World!")
。python3 hello.py
,驗證輸出是否正確。test_example.py
),使用 unittest
模塊編寫測試用例。python3 -m unittest test_example.py
,查看測試結果。python3 -m venv myenv
。以上方法覆蓋基礎功能驗證、代碼測試及環境隔離,可根據需求選擇使用。