Time of Update: 2018-07-26
1.簡單的將日誌列印到螢幕 import logging logging.debug('This is debug message') logging.info('This is info message') logging.warning('This is warning message') 螢幕上列印:WARNING:root:This is warning message
Time of Update: 2018-07-26
blog.ericsk.org/archives/815 標題有沒有殺人,照著作一遍就知道囉。 在 Ruby on Rails 的官方網站上有 15 分鐘作出一個 weblog 的 screencast,的確 demo 了 RoR 開發的快速。不過萬萬不可太迷信只有 RoR 能這麼神速,根據最近擠出一點時間看 django 的東西後,我也想先來作個「10分鐘做出 blog 的挑戰」。(由於還不太會用製作 screen cast
Time of Update: 2018-07-26
列印錯誤跟蹤的方法: 方法1.列印到螢幕 try: i = 0 mydbhandler.executemany(sql, tmp) logging.info("[total cost time:" + str((time.time() - start)*1000) + "ms]") print "
Time of Update: 2018-07-26
#couchbasescript.py#!/usr/bin/python# -*- coding:gbk -*-#程式功能 驗證couchbase中的鍵是否對應mysql表的值from couchbase.bucket import Bucketimport ConfigParserimport MySQLdbimport timeimport os#couchbase配置cp=
Time of Update: 2018-07-26
一個簡單的使用情境:一件商品的庫存只有5件,同時A使用者買了5個,B使用者買了5個,都提交資料,照成庫存不足的問題。 邏輯:根據一般電商商品的模型類,產生訂單一般包括訂單類(Order)和訂單詳情類(DetailOrder),這兩張表根據外鍵order_id
Time of Update: 2018-07-26
代碼很簡單,不到5k行。但是思路挺好的,改成non-blocking了之後效率就是能提高不少,特別是考慮到現代的web app都需要和其他的HTTP伺服器通訊,blocking的代價太大了。 Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. The FriendFeed application is written using
Time of Update: 2018-07-26
Python語言特性 1 Python的函數參數傳遞 看兩個例子: a = 1def fun(a): a = 2fun(a)print a # 1 a = []def fun(a): a.append(1)fun(a)print a # [1] 所有的變數都可以理解是記憶體中一個對象的“引用”,或者,也可以看似c中void*的感覺。 通過id來看引用a的記憶體位址可以比較理解: a = 1def fun(a):
Time of Update: 2018-07-26
server.py檔案: #!/usr/bin/env python#coding:utf-8import SocketServer,osclass MyServer(SocketServer.BaseRequestHandler): def handle(self): base_path = r'C:\Users\91135\Desktop\test' conn = self.request print 'connected...'
Time of Update: 2018-07-26
機器學習的基本架構: 模型(model)、目標(cost function)、最佳化演算法 Step1:對於一個問題,需要首先建立一個模型,如迴歸或分類模型; step2:通過最小分類誤差、最大似然或最大後驗機率建立模型的代價函數; step3:最佳化問題求解 a.如果最佳化函數存在解析解,則可以通過一般的求值方法-對代價函數求導,找到倒數為0的點,即是最大值或者最小孩子; b.如果上述方法求最佳化函數導數比較複雜,可利用迭代演算法也求解。 對於迴歸問題:
Time of Update: 2018-07-26
用PYTHON語言進行資料庫編程, 至少有六種方法可供採用. 我在實際項目中採用,不但功能強大,而且方便快捷.以下是我在工作和學習中經驗總結. 方法一:使用DAO (Data Access Objects) 這個第一種方法可能會比較過時啦.不過還是非常有用的. 假設你已經安裝好了PYTHONWIN,現在開始跟我上路吧…… 找到工具列上ToolsàCOM MakePy utilities,你會看到彈出一個Select
Time of Update: 2018-07-26
代碼很簡單,不到5k行。但是思路挺好的,改成non-blocking了之後效率就是能提高不少,特別是考慮到現代的web app都需要和其他的 HTTP伺服器通訊,blocking的代價太大了。 Tornado is an open source version of the scalable, non-blocking web server and tools that power FriendFeed. The FriendFeed application is written
Time of Update: 2018-07-26
公司的一台伺服器安裝了海量搜尋,但這個搜尋程式真的很有問題,經常導致tomcat崩潰,於是不得不每次去重啟。 我用python寫了一個指令碼,來監測tomcat是否運行中,如果沒有運行就啟動它。 指令碼代碼 : #!/usr/bin/pythonimport subprocessimport datetimeres = subprocess.Popen(“ps -ef | grep
Time of Update: 2018-07-26
前言 之前使用Rabbitmq部署了一個簡單的MQTT伺服器,暫未做使用者隔離,也部署了InfluxDB時序資料庫,但是並不能直接通過配置將MQTT伺服器的資料轉存至時序資料庫中,於是我決定自己寫指令碼實現下. 準備 開啟shell使用 pip install influxdb安裝InluxDB所需模組 pip install paho-mqtt安裝Rabbmq所需模組 源碼 # coding=utf-8import jsonimport randomimport
Time of Update: 2018-07-26
標籤:pen print python NPU .com info color put_user put 1 # coding=utf-8 2 name_l = []
Time of Update: 2018-07-26
標籤:nbsp for new style turn 簡潔 pen 列表 推導式 1、三元運算式# 什麼是三元運算式 三元:三個元素x=1y=2if x>y:
Time of Update: 2018-07-26
標籤:element 圖片 class www. 輸入 tps 出錯 index 指令碼 1.下載Chrome上一篇文章已經示範過了Python+Selenium+Firefox+Geckodr
Time of Update: 2018-07-26
標籤:nta locking epoll 執行順序 緩衝 選擇 監聽 安全 位置 目錄一、理解作業系統二、任務類型三、Socket模組四、一個簡單的C/S程式五、使用阻塞IO實現並發方案一:阻塞
Time of Update: 2018-07-26
標籤:tle 參數 str Fix wap index 布爾 大小寫 sla 字串的操作 capitaliza() str.capitaliza() 方法返回一個
Time of Update: 2018-07-26
標籤:正常化 輸入 tps time lse search 括弧 資料 python 說明該計算機主要是為了練習Regex以及python基礎所寫:代碼比較low! 運行過程請輸入你的
Time of Update: 2018-07-26
標籤:locking def ESS on() process daemon 程式 python 防止 ------------------------------線程-------------