原创 python 3.x 求階乘,遞歸

求階乘,採用遞歸函數:   def factorial(n): if n == 0 or n == 1: return 1 else: return (n * factorial(n -1

原创 python 3.x函數裝飾器

函數對象在被調用時,函數裝飾器將會起作用:   from time import ctime,sleep def tsfunc(func): def wrappedFunc(): print('[%s] %s(

原创 python的堆棧stack和隊列queue

一、python的堆棧遵守:先進後出的原則。 stack = [] def pushit(): stack.append(input('Enter new string:').strip()) def popit():

原创 python 3.X運用字典登錄的例子

運行字典進行登錄的例子,含創建用戶,登錄用戶,和退出操作。 db = {} def newuser(): prompt = 'login desired:' while True: name = inp

原创 filter運行判斷素數提示filter object at 0x03DFDA60

用filter來判斷素數,提示<filter object at 0x03DFDA60>,發現filter的結果是一個數組 需要 list 。 將print(newlist)修改爲print(list(newlist)),修改後: de

原创 except IOError,e python3.X中提示語法錯誤

將:except IOError,e修改爲except IOError as e 運行成功。   try: f = open('blah','r') except IOError as e: print('could n

原创 python 3.x獲取素數的例子

python3.x獲取素數: def showMaxFactor(num): count = num // 2 while count > 1: if ((num % count) == 0):

原创 IDispatch接口 - GetIDsOfNames和Invoke

  IDispatch接口是COM自動化的核心。其實,IDispatch這個接口本身也很簡單,只有4個方法:   1 IDispatch : public IUnknown 2 { 3 public: 4

原创 python的類都隱含有一個__init__函數

python的類都隱含有一個__init__函數,類在實例化的時候自動調用,類似C++中的構造函數。可以重載此函數,並將類初始化時需要做的操作放入此函數中。 class FooClass(object): 'my very fi

原创 python的print輸出不換行

在python3.8.1中採用: def addMe2Me(x): return (x + x) result = addMe2Me(2.3) print(result,end='') result = addMe2Me("Py

原创 Python3.x取虛隨機數

import random print("randrange(100,1000,2):",random.randrange(100,1000,2)) print("randrange(100,1000,3):",random.randr

原创 MYSQL安裝入門

原文鏈接:https://blog.csdn.net/qq_28286027/article/details/81194208 mysql安裝過程及注意事項:  1.1. 下載: 我下載的是6

原创 BMP的圖片格式(編程)

一.簡介 BMP(Bitmap-File)圖形文件是Windows採用的圖形文件格式,在Windows環境下運行的所有圖象處理軟件都支持BMP圖象文件格式。Windows系統內部各圖像繪製操作都是以BMP爲基礎的。Windows 3.0