Time of Update: 2018-07-29
Python代碼:ClearWindow.py """ Clear Window Extension Version: 0.2 It provides "Clear Shell Window" under "Options" with ability to undo. Add these lines to config-extensions.def [ClearWindow] enable=1 enable_editor=0
Time of Update: 2018-07-29
在qq群裡面看到一道小學的數學題: 原諒我不是機智的小學生了(我相信一定有簡單的方法),也嫌棄高等數學的積分方法。。。於是想用程式解決它,不想費腦。於是又想到了一個經典的演算法:蒙特卡洛方法,具體可以參照20世紀十大偉大的演算法。 這道題目的關鍵就是求出右上方那個偽三角形的面積。這樣問題就迎刃而解了。單獨看右邊正方形右上的四分之一的正方形,下圖的紅色框框部分~~
Time of Update: 2018-07-29
1. 使用函數 np.random.random 由於 np.random.random() 預設產生 0~1 之間的小數,因此需要轉換一下 如產生 3*3 的 -1~1 之間的隨機數矩陣
Time of Update: 2018-07-29
1、二叉樹的遍曆方式。 前序走訪:根左右 中序遍曆:左根右 後序遍曆:左右根 層次遍曆:從上到下,從左至右 2、python建立一個二叉樹及其七種遍曆(遞迴和非遞迴) class Node(): #節點類 def __init__(self,data = -1): self.data = data self.left = None self.right = Noneclass Tree(): #樹類
Time of Update: 2018-07-29
早上看到一篇公眾號在推xgboost、lightgbm、catboost原理比較,網上大概查了下原理及介面使用,目前只提供python、R、C/C++介面,並沒有看到java介面,這個演算法還算比較新穎,下面簡單的用python調用去介面看看,沒太多的技術含量,模型訓練、儲存、載入都可以看到,好像也提供service服務:關於介面參數說明可以參考 這篇文章: http://blog.csdn.net/aiirrrryee/article/details/78224232
Time of Update: 2018-07-29
轉自Python之%s%d%f,轉載備用,若侵權請聯絡博主刪除 %s string="hello" #%s列印時結果是hello print "string=%s" % string # output: string=hello #%2s意思是字串長度為2,當原字串的長度超過2時,按原長度列印,所以%2s的列印結果還是hello print "string=%2s" % string
Time of Update: 2018-07-29
1、簡單例子 總體來講,python的類和C++的類,思想上是一樣的。只是文法會有略微的差別,所以這裡主要關注文法。先上個簡單例子: class base (object): static_v = 100 def __init__(self): self.x = 0 self.y = 0 self.z = 0 print 'aaa', self.x, self.y, self.z def pr(self):
Time of Update: 2018-07-29
1、運用turtle庫函數實現繪製不同幾何圖形,並做填充處理: # TurtleTest.pyimport turtledef main(): turtle.speed(2) turtle.pensize(3) turtle.penup() turtle.goto(-200,-50) turtle.pendown() #表示開始做圖形填滿 turtle.begin_fill() turtle.color('red')
Time of Update: 2018-07-29
描述: python split() 通過指定分隔字元對字串進行切片,如果參數num 有指定值,則僅分隔 num 個子字串 方法解釋: def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__ """ S.split(sep=None, maxsplit=-1) -> list of strings
Time of Update: 2018-07-29
# -*- coding: utf-8 -*-"""Created on Sat Oct 22 21:01:23 2016@author: hhxsym"""import requestsimport jsonimport osimport pymongoimport timefrom bs4 import BeautifulSoupfrom multiprocessing import Pool
Time of Update: 2018-07-29
博文1:pandas.read_csv——分塊讀取大檔案 http://blog.csdn.net/zm714981790/article/details/51375475 今天在讀取一個超大csv檔案的時候,遇到困難: 首先使用office打不開 然後在python中使用基本的pandas.read_csv開啟檔案時:MemoryError 最後查閱read_csv文檔發現可以分塊讀取。
Time of Update: 2018-07-29
source: http://blog.163.com/lxq_102172/blog/static/133398015201231012213428/ # -*- coding: utf-8 -*-from __future__ import divisionimport wximport mathlabels='1 1 1 1 1 MC MR MS M+ M- <- CE C +- Sqr 7 8 9 / % 4 5 6 * 1/x 1 2 3 - 0 0 . . + 2'
Time of Update: 2018-07-29
前三篇部落格已經介紹了,如何利用selenium去爬取一個指定內容的百度文庫的文章連結和文章的名稱,接下這篇部落客要介紹的是,針對於一篇文章我們應該如何去爬取所有的內容 1、分析文章的頁面結構,文章地址https://wenku.baidu.com/view/1d03027280eb6294dd886cb7.html?from=search 通過上圖我們可以觀察到,開啟文章連結之後,可能有的文章顯示不全需要點擊“繼續閱讀”按鈕之後,才能看到所有的內容。 if
Time of Update: 2018-07-29
Python 安裝PIL (python Imaging Library ) 提示 [python] view plain copy
Time of Update: 2018-07-29
1. lower_bound(nums, target) 在非遞減數組nums中,lower_bound(nums, target)返回第一個大於等於target的值得位置,如果nums中元素均小於target(即不存在>=target的元素),則返回nums的長度(即target如果要插入到nums中,應該插入的位置)
Time of Update: 2018-07-29
一、簡介 Python的條件和迴圈語句,決定了程式的控制流程程,體現結構的多樣性。須重要理解,if、while、for以及與它們相搭配的 else、 elif、break、continue和pass語句。 二、詳解 1、if語句
Time of Update: 2018-07-29
paramiko 不通過密鑰檔案登陸,這很好解決,直接connect輸入使用者名稱和密碼就ok # -*- coding: utf-8 -*-import paramikoparamiko.util.log_to_file('paramiko.log') #記錄記錄檔ssh =
Time of Update: 2018-07-29
2. 字串標示符, 修改6-1的idcheck.py指令碼,使之可以檢測長度為一的標示符,並且可以識別python關鍵字, 對後一個要求,你可以用keyword模組(特別是keyword.kwlist)來輔助 原始碼: 'This is a module of idcheck for keyword' import keyword import string kw = keyword.kwlist num = string.digits letters =
Time of Update: 2018-07-29
如果想用python來開發圖形化介面,有很多工具供選擇,各有利弊,之前用過wxPython+Boa-constructor,已經記不清了。 新瞭解了下PyQt4,貌似用這個的人也比較多,所以決定開始學這個。version:PyQt-Py2.7-x86-gpl-4.9.1-1.exe PyQt4內建一個qt designer,用它來建立介面,布局控制項,例如Form,button,text之類的非常方便,利用“編輯訊號/槽”模式定義事件等。
Time of Update: 2018-07-29
一 安裝python (1)下載python3.4.3 (2)安裝python3.4.3 (3)配置環境變數 二安裝numpy (1)下載numpy (2) 解壓縮, 我解壓檔案存放在: (3)切換到numpy-1.9.2目錄下,使用 gfortran進行編譯在(可以使用): python setup.py build --fcompiler=gnu95