原创 Python3內置函數(51-60)

# 51.delattr() # 用於刪除屬性。 class A(object): x = 12 y = 23 delattr(A, 'x') # 52.format() # Python2.6 開始,新增了一種格

原创 Python3內置函數(31-40)

# 31.dict() # 用於創建一個字典。 dic1 = dict(a='a', b='b', t='t') # 傳入關鍵字 print(dic1) dic2 = dict(zip(['one', 'two', 'three'],

原创 Scipy的簡單使用

SciPy是一款方便、易於使用、專爲科學和工程設計的python工具包,它包括了統計、優化、整合以及線性代數模塊、傅里葉變換、信號和圖像圖例,常微分方差的求解等 官方:https://www.scipy.org/ 使用前安裝該模塊:使用

原创 利用2to3簡單實現python2轉python3

參考內容:https://docs.python.org/zh-cn/3.7/library/2to3.html   然後新建文件:python 2to3.reg 文件內容: Windows Registry Editor Versio

原创 Python3的time模塊的使用

import time # 1.time() print(' python誕生總時間(1970):', time.time()) # 2.asctime() print('當前時間:', time.asctime()) # 當前時

原创 Python3的re模塊的使用

import re # 2元字符 . ^ $ * + ? { } [ ] | ( ) \ # 作用:匹配字符串 s = 'hello world' # 返回開始位置 下標 print(s.find('llo')) # 找到 並替換

原创 Python3內置函數(10個)

# 1.abs() print(abs(-23)) # 返回數字的絕對值 # 2.divmod() print(divmod(15, 6)) # 返回元組(15/6,15%6)支持複數 # 3.input() print(input

原创 Python3內置函數(61-69)

# 61.max() # 返回給定參數的最大值,參數可以爲序列。 lst1 = (1, 2, 45, 6, 7, 64, 32, 14) print(max(lst1)) # 62.memoryview() # 返回給定參數的內存查看

原创 Python3的random模塊的使用

import random print(random.random()) # 默認限制在0-1的小數 print(random.randint(1, 8)) # 1-8的整數 包含1和8 print(random.choice

原创 Python3內置函數(11-20)

# 11.any() # 與all()相反,判斷是否全爲False 除了0,空,False,None都算True a1 = [0, False, ''] # a1 = [0, False, ' '] 注意最後的''與' ' 空指的是'

原创 Python3內置函數(21-30)

# 21. bin() # 返回一個整數 int 或者長整數 long int 的二進制表示。 num1 = bin(10) print(num1) # 22. file() # file() 函數用於創建一個 file 對象,它有一

原创 Python3內置函數(41-50)

# 41.sorted() # 對所有可迭代的對象進行排序操作。 # sort 與 sorted 區別: # sort 是應用在 list 上的方法,sorted 可以對所有可迭代的對象進行排序操作。 # list 的 sort 方法返

原创 Python3的configparser模塊的使用

import configparser config = configparser.ConfigParser() # 字典模式生成配置文件 # 第一個section config['DEFAULT'] = { 'A': 'a

原创 scikit-learn的簡單使用

專門用於機器學習的模塊。分類,迴歸,無監督,數據降維,數據預處理等等,包含了常見的大部分機器學習方法。 官網:https://scikit-learn.org 使用前安裝該模塊:使用pycharm可以進入 Settings-> Proj

原创 Python3的hashlib模塊的使用

import hashlib m1 = hashlib.md5() m2 = hashlib.sha1() m3 = hashlib.sha3_256() m4 = hashlib.sha512() # 不加鹽 m_4 = hash