原创 python使用re, os, httplib, urllib批量下載網頁上的圖片

import re ,httplib, urllib, os conn = httplib.HTTPConnection("www.njupt.edu.cn") """ 下面這行代碼可以用httplib提供的其他幾個方法實現

原创 python簡單程序使用signal模塊處理僵死進程

程序一:未使用信號處理程序 #! /usr/bin/python import socket, os """ 簡單網絡程序,每次連接後派生的子進程終止後都會成爲僵死進程 """ serSock = socket.socket(s

原创 python編寫藉助linux中的xinetd守護進程實現我們的網絡程序(select、重定向標準輸入輸出)

典型的unix存在許多服務器。4.3 BSD面世之前,所有的這些服務都有進程與之關聯。這些程序遵循unix系統服務的啓動流程。而且每個服務執行幾乎相同的啓動任務:    (1 )創建套接字,將端口綁定在套接字上      ( 2 ) 等

原创 python with使用的一些例子

while this might look like magic, the way Python handles with is more clever than magic. The basic idea is that the st

原创 python的udp服務器多進程編程

這裏只演示os.fork派生子進程 """ 僅僅是演示udp的多進程服務器編程,未使用信號處理函數處理僵死進程 """ import socket, os ser = socket.socket(socket.AF_INET,

原创 python使用xlrd xlwt操作Excel

這裏主要示範模塊的一些簡單實用方法,方便以後查閱: import xlrd import xlwt import sys """下面是xlrd模塊的一些簡單實用方法""" fileName = "testFile.xlsx" fd

原创 使用python實現linux下守護進程(初學,瑕疵多)

<pre name="code" class="python">#! /usr/bin/python import os, sys, time def daemon(logfile, errfile): """ 此

原创 關於python的threading.Thread.daemon 與 multiprocessing.Process.daemon的疑問

什麼是daemon:    http://www.cnblogs.com/itech/archive/2011/08/22/2149684.html 這篇文章大致給出了linux下的某些服務    http://blog.csdn.net

原创 MySql的七種表類型(存儲引擎)

root@(none) 02:21:54>show engines; +--------------------+---------+----------------------------------------------------

原创 python 裝飾器 上下文管理器 迭代器 生成器 描述符

(1)裝飾器,語法糖 (2)上下文管理器,實現__enter__ __exit__方法,使用contextlib模塊,配合生成器對象可以產生一個上下文的管理器 (3)迭代器,注意和可迭代區分,list、dict對象都是可迭代對象但不是迭代

原创 python exception

class MyException(Exception): def __init__(self, string, num): Exception.__init__(self, string, num)

原创 python contextlib.py

"""Utilities for with-statement contexts.  See PEP 343.""" import sys from functools import wraps from warnings i

原创 saltstack一些簡單的總結--關於幾個簡單的任務(4)

鏈接一:https://docs.saltstack.com/en/latest/ref/states/all/salt.states.ssh_auth.html#control-of-entries-in-ssh-authorized-

原创 在systemd下如何編寫我們的守護進程,利用systemd管理我們的守護進程

       前言:在sysv init與upstart方式下,我們編寫守護進程的方法可參見我寫的其它文章,但思想與方法來源都是那本聖經《unix環境高級編程》,基本思路就是兩次fork,調用setsid()脫離終端(如果有的話),標準輸

原创 saltstack相關的一些總結

master配置如下: file_roots: base: - /srv/saltreactor: - 'salt/minion/*/start': - /var/salt/reactor/firstconnec