计算机‎ > ‎软件‎ > ‎Linux‎ > ‎

树莓派上的 python

发布者:guo rue,发布时间:2016年2月15日 22:41   [ 更新时间:2016年2月15日 22:47 ]
树莓派是默认安装了 python 的那么来写一些 python 程序吧。
运行 python 有两种方式,一种是交互方式,一种文件运行方式。

交互方式例子
python

输出打印“世界,你好”
print("hello,world")
hello,world

数学运算
1+2+3
6

退出 python 交互程序
exit()
或者按键盘的 Ctrl + D 也可以退出 python 交互程序

文件运行方式例子
nano hi.py
写入以下代码
print("hello,world")
保存退出

执行
python hi.py
hello,world