如何学习Python?

How do I learn Python?

这篇文章摘自Quora,讲的是如何学习Python。给我最大的收获不是教我如何去学习Python,而是那句“找到是什么在激励着你”)(Find what motivates you),学习本身应该也算是一种享受了。动机是关键的所在,找到自己的学习动机,自己驱动着自己保持学习下去。

正文:

The most important question to answer first is why do I want to learn python? Answering this will guide what you use to learn and how you learn.

Starting with a very generic list of resources to learn python when you eventually want to make websites (for example), will not only reduce your motivation, it will also make it much harder to apply the knowledge you gain. I‘ve tried to learn coding without context and application, and I‘ve almost never come out of it with any meaningful skills.

When I learned python 3 years ago, I wanted to create websites. It shouldn‘t come as a shock to anyone that the best way to learn how to do this was to create websites.

1. Find what motivates you

Finding and keeping your motivation is key -- I slept through a lot of the one high school programming class I took because it made us memorize a bunch of syntax. On the other hand, when I needed to learn python to make an automated essay scoring algorithm, I stayed up many late nights learning and iterating.

Motivation is rarely addressed in learning -- you‘re often just given a list of generic tutorials to try, and told to go do them. But the great thing about python is that you can develop almost anything, from mobile apps to games to advanced machine learning algorithms. No matter what you‘re interested in, you can probably build it in python, and there‘s probably a good getting started tutorial.

Pick an area or two that you‘re interested in, and stick with them-- you‘ll be developing quite a few projects in the areas.

Here are some sample areas, but feel free to add your own:

  • Websites
  • Mobile apps
  • Games
  • Data science/Machine learning

2. Learn some basic python syntax

Unless you know the basic syntax, it‘s hard to implement anything. That said, don‘t spend too long on this. The goal is to learn the very basics, so you know enough to start working on your own projects in your areas(s) of interest.

For reference, I spent less than a week on codecademy, and went through about 30% of the material. This was enough to get started on a project.

Some resources that can help you:

I can‘t emphasize enough that you should only spend the minimum amount of upfront time possible on basic syntax. The quicker you can get to working on projects, the faster you will learn. You can always refer back to the syntax when you get stuck later.

3. Make structured projects in your chosen area

Unless you actually apply your knowledge, you won‘t be able to retain it well. Projects are a great way to learn because they push your capabilities, show you how to apply skills, and give you a portfolio to show employers in the future.

When you start out, it can be helpful to have more structured projects with some guidance. Here are a few ideas:

Games

  • Codecademy -- walks you through making a couple of simple games.
  • Pygame tutorials -- pygame (the python library for making games) has a good list of tutorials
  • Making games with pygame -- this book looks like a great way to learn python by making games

Websites

  • Flask tutorial -- the official flask (simple python web framework) tutorial.
  • Bottle tutorial -- Bottle (even simpler web framework for python) tutorial.
  • How To Tango With Django 1.7 -- a guide to using django (more complex python web framework)

Mobile apps

  • Kivy guide -- Kivy is the tool that lets you make mobile apps with python. They have a guide on how to get started.

Data science

  • Dataquest.io -- Teaches you python and data science interactively. You analyze a series of interesting datasets ranging from CIA documents to NBA player stats.
  • Scikit-learn documentation -- Scikit-learn (the main machine learning library for python) has some great documentation and tutorials.
  • Python for Data Analysis -- written by the author of a major python data analysis library (pandas), it‘s a good introduction to analyzing data in python.

4. Work on projects on your own

Once you have learned the concepts in a guided manner, it‘s time to work on some projects on your own. You‘ll still need to consult references and look up concepts, but you‘ll be fitting what you learn into the needs of your project, not the other way around.

Finding other people to work with here can both help you learn and help keep you motivated.

Some ideas:

  • Extend the projects you were working on previously, and add more functionality.

    Go to python meetups in your area, and find people who are working on interesting projects.

  • Find open source packages to contribute to.
  • See if any local nonprofits are looking for volunteer developers.
  • Find projects other people have made, and see if you can extend or adapt them.

My first project was adapting my automated essay scoring algorithm from R into python. It didn‘t end up looking pretty, but it started me on the journey to learning python.

The key is to pick something and do it. If you get too hung up on picking the perfect project, there‘s a risk that you‘ll never make one.

5. Keep working on harder projects

Keep increasing the difficulty and scope of your projects. If you‘re completely comfortable with what you‘re building, it means it‘s time to try something harder.

Here are some ideas for when that time comes:

  • Try teaching a novice how to do your current project.
  • Try load testing your website -- can you scale it up?
  • Can you make your program run faster?

Going forward

At the end of the day, python is evolving and changing all the time. There are probably only a few people who can legitimately claim to completely understand it.

You‘ll need to be constantly learning and working on projects. If you do this right, you‘ll find yourself looking back on your code from 6 months ago and thinking about how terrible it is. If you get to this point, you‘re on the right track.

Python is a really fun and rewarding language to learn, and I think anyone can get to a high level of proficiency in it if they find the right motivation.

原文地址:https://www.cnblogs.com/crb912/p/9179415.html

时间: 2024-10-13 08:36:48

如何学习Python?的相关文章

学习Python随想

进入大三之后进入了一周基本都是专业课的状态,虽然相比之前几个学期课时量减少了,但实际上学要学习的任务却大大增加了,而类似于Python,spss这一类的课程是之前之前并没有听说过的,但在上过两周之后发现,Python是类似于c语言一类的课程,而之前的c语言和数据结构学得并不好,所以其实在内心深处是有一丝丝的惧怕的,希望在实践课上能多做一些类似于第一次的学打代码的联系,多找找感觉. 课堂进度十分之快,时而跟得上时而跟不上,而一旦跟不上就会跟多米诺骨牌似的,影响接下来的课堂学习.在智慧云教室最大的感

【个人计划】告别英雄联盟,开始学习Python

不知不觉中接触英雄联盟已经快两年了,记得是大四那年找完工作,一下比较清闲,宿舍刚好有lol的氛围,于是乎,四个新手在何大神的带领下,走上了lol的道路.不得不说,从那以后,花费在lol上的时间太多啦,据我估计,个人玩了将近2000了吧,别看局数这么多,其实就是个渣渣,技术太菜了,这也就是我告别英雄联盟的原因啦,根本没有玩这个游戏的天赋,技术上没有一点点提高,一直就是在浪费时间罢了. 就我个人而言,1.在补兵方面,时好时坏,而且有时候性子急,不太注重前期的补兵发育,往往导致输的结局:2.游戏中大部

学习python第一天

学习Python第一天 Python小白,做Linux运维5年,纯系统运维已经不能满足日常工作需要,所以学习Linux运维开发入门级语言python 前言: Python, 是一种面向对象.解释型计算机程序设计语言,由Guido van Rossum于1989年发明,第一个公开发行版发行于1991年. Python是纯粹的自由软件, 源代码和解释器CPython遵循 GPL(GNU General Public License)协议. Python语法简洁清晰,特色之一是强制用空白符(white

重新学习python系列(一)? WTF?

重新学习python:两年前学了点python之后就一直没做做过啥项目, 基本上全忘光了,复习一下搞点事情 or |and & ord() ascii转16进制 chr()  16进制转ascii >>> u'ABC'.encode('utf-8') 'ABC' >>> u'中文'.encode('utf-8') '\xe4\xb8\xad\xe6\x96\x87' >>> 'abc'.decode('utf-8') u'abc' >&g

Python学习--Python基础语法

第一个Python程序 交互式编程 交互式编程不需要创建脚本文件,是通过 Python 解释器的交互模式进来编写代码. linux上你只需要在命令行中输入 Python 命令即可启动交互式编程,提示窗口如下: Window上在安装Python时已经已经安装了默认的交互式编程客户端,提示窗口如下: 在Python提示符中输入一下文本,然后按回车查看运行结果: print 'hello world'; 输出: hello world 脚本式编程 让我们来写一个简单的Python脚本,所有的Pytho

几条学习python的建议

熟悉python语言, 以及学会python的编码方式. 熟悉python库, 遇到开发任务的时候知道如何去找对应的模块. 知道如何查找和获取第三方的python库, 以应付开发任务. 学习步骤 安装开发环境 如果你在window下, 去下载pythonxy安装起来, 然后运行python, 进入python解释环境. 如果你在ubuntu下, 执行: sudo apt-get install python, 然后在命令行下运行python, 进入python解释环境. 学习方法 作为一名成熟的

鱼C《零基础入门学习Python》10-17节课时知识点总结

第10讲:列表:一个打了激素的数组 1. 列表都可以存放一些什么东西?  我们说 Python 的列表是一个打了激素的数组,如果把数组比喻成集装箱,那么 Python 的列表就是一个大仓库,Ta 可以存放我们已经学习过的任何数据类型. 2. 向列表增加元素有哪些方法?  三种方法想列表增加元素,分别是:append().extend() 和 insert().    3. append() 方法和 extend() 方法都是向列表的末尾增加元素,请问他们有什么区别?  append() 方法是将

学习python的小随笔

Python在课表中的名字是高级语言程序设计.上了两周的专业课,我想说我真的是想来学教育的,现在成了计算机了.我还想说,有没有一种可以用中文写程序的软件,有志向的大佬们赶紧弄个吧!       其实关于学习Python倒是不反感,无论是当初学习c++,还是现在学Python,都感觉这个东西挺有意思的.当你能把一个程序写出来并且运转成功之后,那种成就感是难以形容的.(哪怕是对着书敲上的)       希望老师教学中.把我们当做一个程序小白,很多老师以为学过了就精通了,可是事实不是那样.个人感觉Py

学习Python的第一课(简单的单元测试)

由于有C#开发基础,感觉学习Python应该不难,主要是一些语法了,再加上现在互联网这么发达. 感觉还是要有思路,否则学什么也只能是什么. 话不多说,简单发下这几天的学习成果吧: 第一次写博客,大家不要见笑啊 简单的语法就不多说了,随便搜搜就可以得到.() 单元测试来了: 要做两个测试: # 用于判断质数 import math def isPrime(n): print ("验证数字"+str(n)+"是否质数开始") print ("开平方:"

人在囧途——Java程序猿学习Python

引言 LZ之前其实一直对python都很好奇,只是苦于平时没有时间去了解它,因此趁着51假期这个机会,便迫不及待的开始了自己的探索.作为一个标准的Java程序猿,在了解python的过程当中,LZ遇到了很多囧事,接下来LZ就一一给大家说道说道.本文纯属看个乐子,非python教学. 囧事一:eclipse插件安装篇 由于LZ习惯了使用eclipse进行开发,因此对python的研究,还是希望可以在eclipse上进行试验.那么第一件事,自然是安装python的eclipse插件,于是百度.goo