Note of "Learn Python the HardWay"

1.SetUp &Environment [Important before Staring!]

        Just use the Notepad++ to edit it, and use the PowerShell(Windows) to run it.-------For a better learning of Python!

2.Print(Output)

      This can be very basic. Just be skillful at "%s, %d, %r".

      Pay attention to the difference of "%s" and "%r"----------  %r is usually used in debugging, it just prints out the raw representation of what you typed.

      %d for integer, %f for float........

3.Input

       Two ways------raw_input() [just don't use input()] orargv

4.Reading & Writing of Files

 

  • close -- Closes the file. Like File->Save.. in your editor.
  • read -- Reads the contents of the file. You can assign the result to a variable.
  • readline -- Reads just one line of a text file.
  • truncate -- Empties the file. Watch out if you care about the file.       should in mode['w']
  • write('stuff') -- Writes "stuff" to the file.    should in mode['w']

5.About Functions

This can be easy because the Function in Python is almost just like it in other languages like Java or C++...

         NoNoNo...Pay attention to use the keyword "def"

6.Reading more codes

Once upon you have know the basic usage, you need to read some codes-----in github or something else.

For example, I'm reading "geekcomputers" from github.com! See you soon. Only to find it to easy(?Nope,,,but it's structure to easy = =?)

Then I find the "kennethreitz/requests" in github. It is a HTTP library written in Python and based on urllib.




Appendix:

1. To get a brief introduction ---------Eg: 

			Windows下输入:python -m pydoc raw_input     [查看函数介绍]


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值