通过习题0的学习,可以通过终端在电脑上建立文件夹和文件,并用TextWrangler打开并编辑。
1,建立文件夹,打开mac的终端,敲入一下指令:
mkdir /users/simengred/mystuff ---- 在文件夹users/simengred下建立一个名叫mystuff的文件夹
cd /users/simengred/mystuff -----切换到mystuff文件夹路径下
touch ex1.py ------建立一个名为ex1.py的python文件
通过以上指令,我们就成功在路径/users/simengred/mystuff的路径下建立了一个ex1.py的文件
2,接下来我们打开TextWrangler软件,Command+O打开这个ex1.py的文件
并写入一下代码:
hello again
i like typing this
this is fun
Yay!printing
i'd much rather you 'not'.
i "I said" do not touch this
simengred's first program
3,点击Command+s保存程序
4,在用终端执行以上程序。如果你没有关闭终端,那目前终端的路径仍然在mystuff的路径。如果已经退出,需要重新切换至mystuff路径下:
①先切换至mystuff文件目录下:cd /users/simengred/mystuff
②执行ex1.py:python ex1.py
5,执行结果如下:
hello again
i like typing this
this is fun
Yay!printing
i'd much rather you 'not'.
i "I said" do not touch this
simengred's first program