基本使用 #
安装与运行 #
安装 #
Mac
brew install python3
Windows
直接访问 官网进行下载
验证安装
python3 -v
第一个程序 #
hello.py
print('Hello World!')
python3 hello.py
REPL环境 #
[TOC]
python3
Gui 环境
idle3
控制台输入输出 #
输入输出 #
输出
print
输出字符串并换行
输入
input(str)
获得一行输入
age = input('How old are you? ')
height = input('How tall are you? ')
weight = input('How much do you weigh? ')
print("So, you're {age} old, {height} tall and {weight} heavy.".format(age=age, height=height, weight=weight))
注释 #
单行注释 #
使用符号 #
# Single Comment