Exercise18、19、20、218(自定义函数, 操作文件相关函数)

ex18.py

 

 

ex19.py

Can give function straight numbers, variable, math, combine math and variable.

 

ex20.py

ex20_test.py

1、current_file = open(input_file),print current_file

2、f.seek(0), 使文件指针回到文件头。"moves the file to the 0 byte (first byte) in the file"

3、f.read(), 读取全部文档,文件指针到最后。

4、f.readline(), 读取文件的一行,每次使用得到新的一行。"reading a line from the file and moving the read head to right after the \n that ends that line."

5、打印f.readline(), 行与行之间有空格。

原因: “The readline() function returns the\n thats in the file at the end of that line.”

解决办法: ”Add a end = "" at the end of“of your print function calls to avoid adding double \n to every line ”

  

 

 

ex21.py

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值