原创 python輸出中文——如何在Windows控制檯打印不亂碼

文章介紹 用Python在控制檯打印中文如何不會亂碼,一直是困擾很多Pythoner的問題,甚至很多Python老手也經常犯難。原因就在於從一般網頁、數據庫或文本外來數據源上抓取過來的內容,需要經過正確的編解碼纔可以正常輸出,而Pytho

原创 Python抓取網頁動態數據——selenium webdriver的使用

文章目的 當我們使用Python爬取網頁數據時,往往用的是urllib模塊,通過調用urllib模塊的urlopen(url)方法返回網頁對象,並使用read()方法獲得url的html內容,然後使用BeautifulSoup抓取某個標籤

原创 linux平臺中socket通信程序的編寫

文檔目的 博主在搭建好的地面與空間通信的模擬通信網絡中,A<--->GW1<--->GW2<--->B之間能夠順利ping通,現在要測試是否能建立TCP連接,開始想直接在B上安裝apache服務器,然後A上的瀏覽器輸入B的ip地址可以訪問

原创 Python實現數據處理——每隔一段時間把數據寫入excel文件中

文章介紹 在上一篇博文中,我講述了利用Python的selenium模塊抓取動態數據的方法點擊打開鏈接,那麼這些抓到的數據如何處理呢?可以寫入到excel表格中製成表格,進而畫成統計圖表直觀顯示出來。例如按照時間軸統計網站的在線人數,查看

原创 python進階——利用網頁爬蟲寫天氣預報採集器

在上一篇博文中,博主通過三個遊戲程序講述了python入門知識點擊打開鏈接,現在再講講如何利用網頁爬蟲來寫一個天氣預報採集器,主要就是在中國天氣網上爬取網頁並過濾數據,得到需要的天氣信息並打印出來。 其實要感謝我同學小黨,他向我展示了他寫

原创 leetcode第20題——*Valid Parentheses

題目 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is v

原创 算法基礎——十種常用排序算法的Java及Python實現

概述 排序算法不用多說了,程序員算法基礎必須要掌握的,現在總結一下加深記憶。下圖是常見八大排序算法的分類、名稱、時間空間複雜度,以及穩定性。 除了以上八大排序算法外,還有兩種在輸入數組符合特定條件下的高效率排序算法: 計數排序:假設輸入數

原创 leetcode第9題——*Palindrome Number

題目 Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Coul

原创 leetcode第17題——**Letter Combinations of a Phone Number

題目 Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit t

原创 leetcode第16題——**3Sum Closest

題目 Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. R

原创 leetcode第15題——**3Sum

題目 Given an array S of n integers, are there elements a,b,c inS such that a + b + c = 0? Find all unique triplets in t

原创 遞歸和非遞歸方法實現斐波那契數列

介紹 斐波那契數列(Fibonacci sequence),又稱黃金分割數列、因數學家列昂納多·斐波那契(Leonardoda Fibonacci[1]  )以兔子繁殖爲例子而引入,故又稱爲“兔子數列”,指的是這樣一個數列:0、1、1、

原创 leetcode第24題——**Swap Nodes in Pairs

題目 Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should

原创 leetcode第23題——***Merge k Sorted Lists

題目 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思路 將數組中的k個有序鏈表歸併

原创 leetcode第22題——**Generate Parentheses

題目 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For examp