原创 Python面向對象編程(3)——類方法、靜態方法

類方法、靜態方法 1 靜態方法      定義形式:@staticmethod裝飾,參數不需要self           靜態方法無法引用或訪問實例屬性,可通過類.類變量訪問類屬性      可以採用類、類實例進行調用      與類相

原创 LeetCode算法題——Reverse Integer

Description: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to sh

原创 Python基礎語法(1)—— 輸入輸出、變量命名規則、List、Tupple等

1 字符串打印採用單引號、雙引號均可,三引號用於打印多行字符串 2 format字符串使用:  age=3  name="Tom"  print("{0} was {1} years old".format(name, age))  可使

原创 LeetCode算法題——String to Integer (atoi)

Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a ch

原创 Spring 松耦合實例

假定我們現在需要輸出不同格式文件,傳統實現方式如下: 1 創建輸出文件接口IGenerateFile.java package com.xidian.edu; public interface IGenerateFile {

原创 Python面向對象編程(2)——深入類的屬性

2 深入類的屬性 2.1 同名的類屬性與實例屬性      在使用實例名.屬性名應用時,優先引用實例屬性      使用類名.屬性名時,只能引用類屬性 classClassAttrDemo1:     a=10    def__init_

原创 LeetCode算法題——Add Two Numbers

Description: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in

原创 LeetCode算法題——ZigZag Conversion

Description: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you ma

原创 LeetCode算法題——Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could ne

原创 LeetCode算法題——Two Sum

原題: Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may

原创 Python面向對象編程(4)——類的繼承與方法重載

類的繼承與方法重載 1 繼承的特點      減少代碼並且靈活的定製新類,子類可以繼承父類的屬性和方法,但另一方面子類無法繼承父類的私有屬性和私有方法,子類可以修改父類的方法,也可以定義新的方法。 2 繼承的語法定義      方式:在類

原创 Python基礎語法(4)——GUI編程及猜數字遊戲

13 圖形界面(GUI)及猜數字遊戲 1 GUI:Graphical User Interface 2 tkinter:GUI library for Python 3 GUI Example 13.1 圖形界面 from tkinter

原创 Python面向對象編程(1)——屬性分類、方法調用

1 面向對象編程      1.1 面向對象編程優點:封裝、繼承、多態、組合      1.2 類說明採用"""三引號,可用類名.__doc__或者help(類名)查看類說明      1.3 描述對象的特徵      1.3.1 實例屬

原创 Python基礎語法(3)——文件流、異常處理、面向對象編程以及裝飾器

10 輸入輸出 10.1 輸入輸出方式介紹      可採用input方式接收控制檯的輸入 str1=input("Please input a string:") print(str1) print("{}".format(st

原创 Python基礎語法(2)——字典、函數定義使用、控制流(if&for&while)

7.3 字典Dictionary(鍵值對)      創建字典:demoDic={"name":"Tom","age":10,"sex":1}      查看key對應的Value值:demoDic["name"]      刪除字典中元