跳到正文
产品桌面工具TASTECAD图纸查看TASTEFILES文件管理TASTEFTP文件传输TASTESSH远程工作空间TASTEZIP压缩与解压开发工具TASTECODERust 集成开发环境TASTESTUDIO集成开发与测试环境TASTEETL数据整合(ETL)服务器TASTEREMOTE远程桌面服务器TASTEGEO空间信息服务器TASTEMAIL邮件工作空间开始使用下载文档购买全部产品
市场
资讯
技术资讯今日开发资讯开发文档编程语言RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb 前端框架Next.jsReactVue.js · NuxtSvelteKitAngular服务端框架Spring BootDjangoFastAPIASP.NET CoreNestJS · Express应用与桌面框架TauriFlutterReact NativeElectron算法算法基础核心算法进阶算法实用算法
社区项目开发日志提示词AI 工具问题作品展示社区指南
合作技术传授网站构建桌面应用构建发布与支付流水线销售合作伙伴联系我们
服务远程桌面安装包定制
TASTEDEV
产品

桌面工具

TASTECAD复杂图纸,轻松打开TASTEFILES只要需要的文件,最快送达TASTEFTP让文件往来,干净利落TASTESSH你与服务器之间,连接更牢靠TASTEZIP压得更快,解得更稳

开发工具

TASTECODE在一个窗口中完成 Rust 应用的编辑、构建、调试和测试TASTESTUDIO从编辑到远程测试,再到经批准的 AI 修复TASTEETL边看数值,边搬数据

服务器

TASTEREMOTE在自己的服务器上运行的远程桌面TASTEGEO用 Rust 重新构建兼容 GeoServer 的空间信息服务器TASTEMAIL把邮件的主导权拿回自己手中

开始使用

下载所有产品的最新版本文档各产品使用方法购买订阅与永久许可全部产品一览全部产品
全部产品
市场资讯
技术

资讯

今日开发资讯语言、框架、GitHub 与 AI 官方发布开发文档语言、框架与算法指南

编程语言

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

框架

Web 前端框架Next.jsReactVue.js · NuxtSvelteKitAngular
服务端框架Spring BootDjangoFastAPIASP.NET CoreNestJS · Express
应用与桌面框架TauriFlutterReact NativeElectron

算法

算法基础复杂度分析 · 排序 · 查找 · 基础数据结构 · 树与堆核心算法图遍历 · 最短路径与最小生成树 · 动态规划 · 贪心算法 · 分治法 · 回溯法进阶算法字符串算法 · 数学与数论 · 位运算 · 线段树 · 并查集实用算法编程面试解题策略 · LRU 缓存 · 限流 · 一致性哈希
查看全部开发文档
社区
项目发现开发者与作品开发日志决策与试错提示词可复用的指令AI 工具问题Claude、Codex、Gemini 的问题与变通办法作品展示已完成的成果社区指南我们如何公开构建
合作
技术传授用 Rust 和 egui 打造原生应用网站构建10 种语言、账户、文档与下载桌面应用构建Rust 和 egui,不用 WebView发布与支付流水线签名、MSI、deb、rpm、AppImage、哈希销售合作伙伴推荐即得 30%联系我们开发、合作与投资咨询
服务
远程桌面用浏览器连接你的电脑安装包定制只装需要的,设置预先放好
购买
ZH
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
登录
登录
TASTEDEV

从小工具到更好的开发。

support@tastedev.net支持 TASTEDEV
产品产品线购买文档下载市场客户支持
社区项目开发日志提示词AI 工具问题作品展示
政策隐私政策服务条款订阅条款退款政策社区规范
账户登录注册
访客
今天
012345678901234567890123456789012345678901234567890123456789
昨天
012345678901234567890123456789012345678901234567890123456789
累计浏览
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
公司名称
GXSOFT
法定代表人
CHOI YOUNG GU
营业执照号
853-44-00368
地址
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
电话
+82-10-4404-1523
电子邮件
whitecalvin@tastedev.net
个人信息保护负责人
CHOI YOUNG GU

© 2026 TASTEDEV产品信息以已验证的开发源码为准。已发布·持续改进

Python 文档
Python
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts
讨论

Python 指南 · 1/6

Getting Started

本章目前仅提供英文版。

This chapter gets a working Python 3 setup onto your machine. You will try code in the interactive interpreter, run a script from a file, give each project its own virtual environment, install packages with pip, and set up an editor that understands your code. By the end you will have a clean, repeatable way to start any new Python project.

Installing Python 3

Python 2 reached end of life years ago, so everything here assumes Python 3. How you install it depends on your platform:

  • Windows: use the installer from python.org or the Microsoft Store. If you use the installer, ticking the option to add Python to PATH saves trouble later.
  • macOS: use the python.org installer or Homebrew (brew install python).
  • Linux: most distributions ship Python already; otherwise install it with your distribution's package manager.

Then check that it works. On Windows, the py launcher is handy because it can pick between installed versions.

python3 --version
# on Windows
py --version

The REPL

Run python3 (or py on Windows) with no arguments and you land in the REPL, a read-eval-print loop. Type an expression after the >>> prompt and the result appears immediately. It is the fastest way to check how a function behaves or to poke at a new library. Use help(len) for built-in documentation, and leave with exit() or Ctrl+D (Ctrl+Z then Enter on Windows).

2 ** 10            # 1024
"python".upper()   # 'PYTHON'
len([1, 2, 3])     # 3
import math
math.sqrt(16)      # 4.0

Running a script

Real programs live in .py files. Save the following as hello.py:

import sys


def main() -> None:
    name = sys.argv[1] if len(sys.argv) > 1 else "world"
    print(f"Hello, {name}!")


if __name__ == "__main__":
    main()

The if __name__ == "__main__": guard means main() runs only when the file is executed directly, not when another module imports it. That small habit keeps your files reusable.

python3 hello.py
python3 hello.py Alice
# -m runs a module by name, here a tiny web server from the standard library
python3 -m http.server 8000

Virtual environments with venv

Different projects need different packages, often at conflicting versions. Installing everything into the system Python quickly turns into a mess. The standard venv module solves this by creating an isolated environment inside your project folder.

# create an environment in a folder called .venv
python3 -m venv .venv

# activate it on macOS or Linux
source .venv/bin/activate

# activate it in Windows PowerShell
.venv\Scripts\Activate.ps1

# leave it
deactivate
对本章有疑问?
下一章Syntax Basics

Once activated, python and pip point into the environment and your prompt shows (.venv). The folder can always be recreated, so keep it out of version control by listing it in .gitignore. If you are ever unsure which interpreter is running, python -c "import sys; print(sys.executable)" prints its path; when that path is inside .venv, the environment is active.

Installing packages with pip

pip downloads packages from the Python Package Index (PyPI). Always install into an activated virtual environment, and prefer python -m pip so there is no doubt about which interpreter receives the package.

python -m pip install requests
python -m pip install --upgrade requests
python -m pip list
python -m pip uninstall requests
CommandWhat it does
pip install nameInstall a package
pip install -r requirements.txtInstall everything listed in a file
pip freezePrint installed packages with exact versions
pip show nameShow details about one package

Setting up your editor

Any text editor will do, but a few features make a big difference:

  1. Language support: in VS Code install Microsoft's Python extension; if you prefer JetBrains tools, PyCharm works out of the box.
  2. Interpreter selection: point the editor at the Python inside your project's .venv, so completion and error highlighting know about the packages you installed.
  3. Formatting and linting: tools such as Black or Ruff keep code style consistent and flag common mistakes on save.
  4. Type checking: mypy or Pyright check your type hints (covered in chapter 3).

Summary

  • Start new work on Python 3 and confirm the install with python3 --version.
  • Use the REPL for quick experiments and .py files for real programs, guarded by if __name__ == "__main__":.
  • Give every project its own environment with python3 -m venv .venv and activate it before working.
  • Install packages with python -m pip install, and make sure your editor uses the environment's interpreter.

0 条评论

热门评论最新优先

登录 · 登录后即可发表评论。