pycharm提示This inspection detects any methods which may safely be made static.


示例代碼:

class Car(object):
	# 未定義任何類屬性

    def move(self):  # 方法會出現下划線提示This inspection detects any methods which may safely be made static.
        print("---車在移動---")

    def stop(self):
        print("---停車---")

原因是該方法不涉及對該類屬性的操作,編譯器建議聲明為@staticmethod,面向對象思想體現

擴展知識
PEP8編碼規范


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM