原创 創建一個Dog類,初始化構造方法具有name和age屬性。Dog類具有坐和打滾的方法。請編寫相應的類並創建對象調用該類。

創建一個Dog類,初始化構造方法具有name和age屬性。Dog類具有坐和打滾的方法。請編寫相應的類並創建對象調用該類。 class Dog(object): def __init__(self,name,age):

原创 python configparse筆記

configparse主要用於在python中進行配置文件的讀取。 基本的讀取配置文件: -read(filename) 直接讀取ini文件內容 -sections() 得到所有的section,並以列表的形式返回 -op

原创 python 我的Tkinter筆記

import tkinter class App: def __init__(self,root): frame = tkinter.Frame(root) frame.pack(sid

原创 讀取一個文件,顯示除了以#號開頭的行以外的所有行。

with open('jing_demo_text',mode='r',encoding='utf-8') as fps: for fp in fps.readlines(): if '#' not in

原创 已知文本文件中存放了若干數字,請編程讀取所有的數字,排序以後進行輸出。

with open('jing_demo_text',mode='r',encoding='utf-8') as fps: numble = map(int,fps.read().split(',')) print

原创 python isdigit()函數

a = '12344' print(a.isdigit()) b = 'as122' print(b.isdigit()) 判斷輸入字符串是否只由數字組成, 若是返回True 若不是返回False 輸出: True False

原创 計算字符串中所有數字的和

333.1211aas2334.121rew12.1112 每一個數取兩位小數 a = '333.1211aas2334.121rew12.1112' import re ret = re.findall(r'[\d]+\.\d{

原创 python pygame筆記

import pygame,sys from pygame.locals import * def RGBChannel(a): return 0 if a<0 else (255 if a>255 else int(a)

原创 python 面向對象的三大特性

封裝,集成,多態

原创 python 爬蟲代碼

https://www.doutula.com/photo/list/?page=1 import requests,os,re,threading,time from lxml import etree from urllib

原创 python selenium筆記

selenium鏈接 selenlum基本使用-操作表單元素,行爲鏈,鍵盤操作 from selenium import webdriver import time driver_path = r"C:\Users\top\Dow

原创 編寫函數,求出“1/(1*2)-1/(2*3)+1/(3*4)-1/(4*5)+1/(5*6)-1/(6*7)+...”前n項的和,函數以n爲參數,它是用戶輸入的。

編寫函數,求出“1/(1*2)-1/(2*3)+1/(3*4)-1/(4*5)+1/(5*6)- 1/(6*7)+...”前n項的和,函數以n爲參數,它是用戶輸入的。 import math n = int(input("請輸入

原创 python我的爬蟲筆記

# *壹 #from urllib import request,parse # 1 #request.urlretrieve('http://www.baidu.com','aaa.html') # # 2 # reas = r

原创 python 我的pymysql筆記

7使用軟件和代碼連接數據庫 import pymysql conn = pymysql.connect(host='localhost',user='root',password='1234',database='pymysql_

原创 使用函數遞歸,計算階乘n! = 1*2*3*4*5...*n。

使用函數遞歸,計算階乘n! = 1*2*3*4*5...*n。 import math n = int(input("請輸入一個數:")) print(math.factorial(n))