笨办法学Python习题1 第一个程序

通过习题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



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值