慕課網(wǎng)的教程看完了,上面的習(xí)題也都能寫出來,但是讓我自己做個什么東西,還是毫無頭緒,聽說學(xué)習(xí)編程的唯一方法就是編程,那我現(xiàn)在編不出來,抄人家博客上的代碼能不能學(xué)會點?
ps:現(xiàn)在正在抄一個百度貼吧爬蟲的代碼。
回復(fù)內(nèi)容:
做了一桌子菜,但都是買現(xiàn)成的熟食,你所做的工作只是切切裝到盤子里。每一個import模塊都相當(dāng)于一塊熟牛肉,但真不能當(dāng)成我們自己做的。 先聲明,我也是剛接觸不久,以下僅是根據(jù)個人經(jīng)驗提出的看法學(xué)編程,第一法則是要懶
怎么個“懶”法?比如我,每天都要上學(xué)校網(wǎng)站登錄帳號才能上網(wǎng),不登陸也要上去看看還有多少流量。但是我不想每天都要為這個重復(fù)下面一系列動作:
打開手機/電腦——>瀏覽器——>學(xué)校官網(wǎng)——>網(wǎng)關(guān)——>輸入帳號登錄
這些動作對于我來說毫無意義且繁瑣,所以我想試著寫一個程序替我做了,剛好最近學(xué)了Python和爬蟲,于是就開始做起來
哎呀,竟然有一個urllib和urllib2庫
哎呀,這樣就可以POST數(shù)據(jù)了
哎呀,可以偽裝成瀏覽器唉
你看,寫著寫著就會了 我是自學(xué)的php,1個月的時候想寫個留言板,寫不出,于是百度了個簡單的留言板源碼,一邊看一邊寫。
2個月的時候把那個留言板改成了博客,隔幾天加個功能,隔幾天加個功能,然后就找到工作了,現(xiàn)在在開發(fā)crm。
剛開始都這樣,就像茶壺煮餃子,有嘴倒不出,主要就是沒有頭緒,只要理清楚第一步干嘛,第二步干嘛,就能想做啥就做啥了。 不邀自答.
零基本或者更多沒有太多編寫完整項目經(jīng)驗的同學(xué), 在初步了解了Python基本語法之后,
可以通過以下方法深入學(xué)習(xí):
- 寫爬蟲, 學(xué)習(xí)Scrapy框架(難度兩顆星)
- 建網(wǎng)站或者建立博客, 學(xué)習(xí)Django框架, 熟悉后轉(zhuǎn)flask框架(難度三顆星)
- 學(xué)習(xí)numpy等包, 用python做科學(xué)計算或者數(shù)據(jù)挖掘等(難度四顆星, 需要一定科研精神)
- 查看Github上Python項目, 看項目源碼, 給項目寫issue->做測試->寫文檔->改Bug->加功能(難度五顆星)
我認(rèn)為學(xué)習(xí)一門語言, 首先應(yīng)該通過網(wǎng)絡(luò)渠道或者實體書渠道, 做一個完整的小項目(不需要太大).
然后推薦兩個自己以前學(xué)習(xí)專欄(掩面, 逃..):
- 鐘愛Python - 文集 學(xué)習(xí)爬蟲系列專題
- Django之歌 - 文集 學(xué)習(xí)Django專題, 最后可以建立一個完整的博客.
最后祝好運! 學(xué)一種程序語言,最好的情況就是帶著需求去學(xué)習(xí)。題主的情況應(yīng)該是學(xué)習(xí)的過程中僅僅是看懂,而沒有加入對如何應(yīng)用的思考,所以學(xué)得不會很扎實,用的時候定位不到對應(yīng)的知識。
我學(xué)習(xí)編程的經(jīng)驗是定一個大目標(biāo),比如完成一個自己的爬蟲,或者完成一個購物網(wǎng)站的推薦算法等等,結(jié)合需求去學(xué)習(xí),這樣你目標(biāo)完成之日就是大功告成之時。
另外推薦英文原版的學(xué)習(xí)資料。
希望有所幫助 或許題主是不知道應(yīng)該做什么。
特別是編程語言一般都對底層功能做了不同程度的封裝來簡化開發(fā),而使用封裝就意味著要使用庫,使用庫就意味著要先知道有什么庫。Python是比C/C++更為抽象的語言,沒有庫寸步難行。
但也不是說要把所有常用庫一個一個學(xué)起來。
一般的做法是挑一個自己想要的功能,然后設(shè)法去實現(xiàn)。這個功能可大可小。然后逐漸往上加功能,自己要什么功能就去學(xué)相關(guān)的知識。
我最早開發(fā)的網(wǎng)絡(luò)爬蟲是一個漫畫下載器(IFComicDownloader),用C++和Windows的SDK寫的。后來為了簡化網(wǎng)絡(luò)(主要是那些檢測reference防外鏈的網(wǎng)站)通信使用了Libcurl,為了便捷添加和修改支持的網(wǎng)站使用了LUA,為了自動更新抓取網(wǎng)頁的腳本而找了個免費的服務(wù)器,為了持久保存數(shù)據(jù)使用了sqlite數(shù)據(jù)庫。昨晚我還修改了一個腳本來繞過某漫畫網(wǎng)站的工口物屏蔽(……)。所以說沒有需求就沒有學(xué)習(xí)的方向。
題主說正在抄百度貼吧爬蟲代碼。按我的觀點,照抄代碼的缺點在于只能知其然很難知其所以然(為什么這里要用list,為什么那邊要用lambda之類的)。這可能導(dǎo)致以后有了需求也想不到怎么處理。而自己有需求的話,帶著問題去找代碼抄,就可以避免這個問題。
與其是抄百度貼吧爬蟲代碼,不如先想想自己覺得爬蟲需要什么功能,然后主動去找資料。先從簡單的開始,比如輸入一個帖子的URL,下載一個帖子的所有回復(fù)(和樓中樓)到文本文件。然后需求自然會慢慢冒出來的。比如如何繞過百度的“非百度用戶無法查看圖片”,如何方便地統(tǒng)計帖子里最活躍的用戶等等。后來可能演變成統(tǒng)計哪幾個用戶彼此關(guān)注,然后搞出一個百度貼吧用戶關(guān)聯(lián)圖。要分析哪幾個用戶是某ID的小號,或者是廣告號,然后沒準(zhǔn)就會去學(xué)習(xí)numpy玩大數(shù)據(jù)統(tǒng)計了。 能學(xué)會編程語言的人很多,用它來做數(shù)學(xué)題的很多,但是有用它來創(chuàng)造產(chǎn)品的人很少,因為大多數(shù)人對沒有做過的事都不知如何下手。所以我認(rèn)為正確的做法是:
1、明確自己要做個什么東西,具有哪些功能。
2、想清楚實現(xiàn)這些功能需要用到哪些技術(shù)。
3、將整個軟件功能細(xì)分,再進行步驟細(xì)分模塊。
4、編碼實現(xiàn)每個功能的每個模塊提供接口并進行調(diào)試。
5、整合接入功能模塊并整體調(diào)試完成開發(fā)。
大二狗,自己做東西時無意總結(jié)出來的方法,慎用。 慕課網(wǎng)。。這幫人就沒打算教你學(xué)會編程啊 你當(dāng)然學(xué)不會啦。。 An Introduction to Interactive Programming in Python
公開課很棒,每講一點會讓你做個小游戲,很簡單,但是用來入門熟悉和培養(yǎng)編程習(xí)慣剛剛好,很有意思,強烈推薦樓主看看,
同在學(xué),可以交流 先找點習(xí)題做做
再找點項目做做。
你的原因是:沒有編程思路。
請看黃哥本人寫的文章
如何捅破python編程的那層紙
https://github.com/pythonpeixun/article/blob/master/pythonstudy.md
剪刀石頭布小習(xí)題三種語言python2、php、go代碼
https://github.com/pythonpeixun/article/blob/master/jdstb.md
一段小代碼說明@property裝飾器的用法
一段小代碼說明@property裝飾器的用法

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Python's unittest and pytest are two widely used testing frameworks that simplify the writing, organizing and running of automated tests. 1. Both support automatic discovery of test cases and provide a clear test structure: unittest defines tests by inheriting the TestCase class and starting with test\_; pytest is more concise, just need a function starting with test\_. 2. They all have built-in assertion support: unittest provides assertEqual, assertTrue and other methods, while pytest uses an enhanced assert statement to automatically display the failure details. 3. All have mechanisms for handling test preparation and cleaning: un

PythonisidealfordataanalysisduetoNumPyandPandas.1)NumPyexcelsatnumericalcomputationswithfast,multi-dimensionalarraysandvectorizedoperationslikenp.sqrt().2)PandashandlesstructureddatawithSeriesandDataFrames,supportingtaskslikeloading,cleaning,filterin

Dynamic programming (DP) optimizes the solution process by breaking down complex problems into simpler subproblems and storing their results to avoid repeated calculations. There are two main methods: 1. Top-down (memorization): recursively decompose the problem and use cache to store intermediate results; 2. Bottom-up (table): Iteratively build solutions from the basic situation. Suitable for scenarios where maximum/minimum values, optimal solutions or overlapping subproblems are required, such as Fibonacci sequences, backpacking problems, etc. In Python, it can be implemented through decorators or arrays, and attention should be paid to identifying recursive relationships, defining the benchmark situation, and optimizing the complexity of space.

To implement a custom iterator, you need to define the __iter__ and __next__ methods in the class. ① The __iter__ method returns the iterator object itself, usually self, to be compatible with iterative environments such as for loops; ② The __next__ method controls the value of each iteration, returns the next element in the sequence, and when there are no more items, StopIteration exception should be thrown; ③ The status must be tracked correctly and the termination conditions must be set to avoid infinite loops; ④ Complex logic such as file line filtering, and pay attention to resource cleaning and memory management; ⑤ For simple logic, you can consider using the generator function yield instead, but you need to choose a suitable method based on the specific scenario.

Future trends in Python include performance optimization, stronger type prompts, the rise of alternative runtimes, and the continued growth of the AI/ML field. First, CPython continues to optimize, improving performance through faster startup time, function call optimization and proposed integer operations; second, type prompts are deeply integrated into languages ??and toolchains to enhance code security and development experience; third, alternative runtimes such as PyScript and Nuitka provide new functions and performance advantages; finally, the fields of AI and data science continue to expand, and emerging libraries promote more efficient development and integration. These trends indicate that Python is constantly adapting to technological changes and maintaining its leading position.

Python's socket module is the basis of network programming, providing low-level network communication functions, suitable for building client and server applications. To set up a basic TCP server, you need to use socket.socket() to create objects, bind addresses and ports, call .listen() to listen for connections, and accept client connections through .accept(). To build a TCP client, you need to create a socket object and call .connect() to connect to the server, then use .sendall() to send data and .recv() to receive responses. To handle multiple clients, you can use 1. Threads: start a new thread every time you connect; 2. Asynchronous I/O: For example, the asyncio library can achieve non-blocking communication. Things to note

Polymorphism is a core concept in Python object-oriented programming, referring to "one interface, multiple implementations", allowing for unified processing of different types of objects. 1. Polymorphism is implemented through method rewriting. Subclasses can redefine parent class methods. For example, the spoke() method of Animal class has different implementations in Dog and Cat subclasses. 2. The practical uses of polymorphism include simplifying the code structure and enhancing scalability, such as calling the draw() method uniformly in the graphical drawing program, or handling the common behavior of different characters in game development. 3. Python implementation polymorphism needs to satisfy: the parent class defines a method, and the child class overrides the method, but does not require inheritance of the same parent class. As long as the object implements the same method, this is called the "duck type". 4. Things to note include the maintenance

The core answer to Python list slicing is to master the [start:end:step] syntax and understand its behavior. 1. The basic format of list slicing is list[start:end:step], where start is the starting index (included), end is the end index (not included), and step is the step size; 2. Omit start by default start from 0, omit end by default to the end, omit step by default to 1; 3. Use my_list[:n] to get the first n items, and use my_list[-n:] to get the last n items; 4. Use step to skip elements, such as my_list[::2] to get even digits, and negative step values ??can invert the list; 5. Common misunderstandings include the end index not
