Time of Update: 2015-06-24
標籤:參考部落格:http://www.cnblogs.com/lhj588/archive/2012/04/23/2466653.htmlhttp://www.cnblogs.com/fclbky/articles/4098204.html參考資料:Python 2.7.7 documentation參考工具:http://translate.google.cn/Available Types:class datetime.date
Time of Update: 2015-06-24
標籤:在學習和使用python的過程中,少不了要與python idle打交道。但使用python idle都會遇到一個常見而又懊惱的問題——要怎麼清屏? 我在stackoverflow看到這樣兩種答案:1.在shell中輸入1 import os2 os.system(‘cls‘) 這種方法只能在windows系統中cmd模式下的python shell 才管用(因為cls的命令是針對cmd的),在python
Time of Update: 2015-06-24
標籤: 在Python 2.x中, socketserver模組名為SocketServer。該模組可以簡化建立伺服器的過程。 該模組有四個比較主要的類型,其中常用的是 TCPServer 和 UDPServer。 1. TCPServer 2. UnixStreamServer,類似於TCPServer提供面向資料流的通訊端串連,但是旨在UNIX平台上可用; 3.
Time of Update: 2015-06-24
標籤:聲明:資源來自慕課網python學習課程,以下只是個人學習總結,僅供參考1.Python類的特殊方法 特徵:以 __ 開頭並結尾的方法,比如用於print的__str__() , __getattr__(),__setattr__()等 不需要在代碼中直接調用, Python的某些函數和操作符會自動調用。 可以自己定製實現,如__str__()方法class Person(object): def
Time of Update: 2015-06-24
標籤: 1. 模組匯入:要使用一個模組,我們必須首先匯入該模組。Python使用import語句匯入一個模組。例如,匯入系統內建的模組 math:import math你可以認為math就是一個指向已匯入模組的變數,通過該變數,我們可以訪問math模組中所定義的所有公開的函數、變數和類:>>> math.pow(2, 0.5) # pow是函數1.4142135623730951>>> math.pi #
Time of Update: 2015-06-24
標籤:import timeimport randomimport threadingimport inspectdef get_current_function_name(): return inspect.stack()[1][3] class Inclass: def __init__(self): print ‘Inclass 初始化‘ def execIn(self,i): rand = int(random.random() * 1
Time of Update: 2015-06-24
標籤:python ftp快速進行ftp上傳 ,下載,查詢檔案利用Python實現ftp伺服器的操作#!/usr/bin/python#ftp.py#this script is used to make some ftp operations more convenient#add upload and download operations 20111210 version0.1import sys,os,ftplib,socketCONST_HOST = "your ftp
Time of Update: 2015-06-24
標籤:python socket python socket之tcp伺服器與用戶端demo作者:vpoet日期:夏季server:# -*- coding: cp936 -*-'''建立一個python server,監聽指定連接埠,如果該連接埠被遠端連線訪問,則擷取遠端連線,然後接收資料,並且做出相應反饋。'''import socketif __name__=="__
Time of Update: 2015-06-24
標籤:1.python中繼承的特點: (1)總是從一個類繼承,預設為object類 (2)不要忘記調用super.__init__方法來初始化父類的方法def __init__(self,args): super(Subclass,self).__init__(args) pass 簡單例子class Person(object): def __init__(self,name,gender): self.name = name
Time of Update: 2015-06-24
標籤:今天運行類型下列代碼與預想中有出入print os.path.abspath(__file__) #檔案不在根目錄os.chdir('/')print os.path.abspath(__file__)#與第一次不一樣但是運行import卻是對的test=import__('xx')os.chdir('/')test=import__('xx')reload(test)原來:1. abspath在linux下的做法只是:1.
Time of Update: 2015-06-24
標籤: 9.6. random — Generate pseudo-random numbers Source code: Lib/random.py This module implements pseudo-random number generators for various distributions.此模組實現偽隨機數產生和各種分布 For integers, there is uniform selection from a range. For
Time of Update: 2015-06-24
標籤:在工作過程中發現監控即時重新整理檔案時,不是那麼的任性。故結合shell中的tail,做了一個類似tail的python指令碼。詳情如下: 1 #!/usr/bin/env python 2 #coding=utf-8 3 import os,sys,time,getopt 4 5 lastline=‘‘ 6 linelist=[] 7 def getNewLine(filename, count): 8 global lastline 9 global
Time of Update: 2015-06-24
標籤:In [8]: a = set(‘abcd‘)In [9]: b = set(‘ef‘)In [10]: def match(x,y): ....: for i in x: ....: for j in y: ....: if i==j: ....: break ....: else: ....: return False ....:
Time of Update: 2015-06-24
標籤:為了便於整理部分業務資料,以及儲存管理, 寫了此指令碼.後期如果有需求,再改一下. 1 #!/usr/bin/env python 2 #coding:utf8 3 4 import os,sys,time,commands,shutil,glob 5 import datetime 6 7 8 class FileSuo: 9 10 def __init__(self,dir):11 self.dir = dir12 13 def
Time of Update: 2015-06-24
標籤:In this guide I will show you how to install Python 2.7 and 3.3 on CentOS 6. The examples below are for Python 2.7.6 and Python 3.3.5, but the procedure is the same for any modern version of Python including the upcoming Python 3.4.0.I make
Time of Update: 2015-06-24
標籤:目錄1、取得目前的目錄——os.getcwd()>>> import os>>> s=os.getcwd()#獲得當前運行指令碼所在目錄>>> s‘C:\\Python27‘比如運行test.py,那麼輸入該命令就會返回指令碼所在的檔案夾位置。例如將test.py放入A檔案夾。並且希望不管將A檔案夾放在硬碟的哪個位置,都可以在A檔案夾內產生一個新檔案夾。且檔案夾的名字根據時間自動產生。>>>
Time of Update: 2015-06-24
標籤:pythonpython相關的基礎知識分享今日面試,,才發現lambda和fibonacci都忘了怎麼寫,一年半載沒有頻繁的用py,以往的興趣因生活的忙碌而顯得生疏了,還好,之前學習整理的文檔都放在了網站上,以備查驗。分享出來解決方案:http://www.pcswo.com/static/file/python/basis/function/generator-eg.py>>> m = lambda x,y,z: (x-
Time of Update: 2015-06-24
標籤:書寫格式,和相關說明如下:格式:\033[顯示方式;前景色彩;背景色m 說明:前景色彩 背景色 顏色---------------------------------------30 40 黑色31 41 紅色32 42 綠色33 43
Time of Update: 2015-06-24
標籤:python hook python hook監聽事件作者:vpoet日期:夏季# -*- coding: utf-8 -*- # # by oldj http://oldj.net/ #import pythoncom import pyHook def onMouseEvent(event): # 監聽滑鼠事件 print
Time of Update: 2015-06-24
標籤:python ping python區域網路alive ip偵聽作者:vpoet日期:夏季注:寫著玩,歡迎copy# -*- coding: cp936 -*-# coding = utf-8import os import reimport threadimport timeimport socketimport sysdef Ping_Ip(Curr_Ip): global