- Python : 3.7.3
- OS : Ubuntu 18.04.2 LTS
- IDE : pycharm-community-2019.1.3
- Conda : 4.7.5
- typesetting : Markdown
""" @Author : 行初心 @Date : 2019/7/7 @Blog : www.cnblogs.com/xingchuxin @Gitee : gitee.com/zhichengjiu """ def main(): # a與b的內容和地址都有差異 a = [1, 2] b = [1] print(id(a), a) print(id(b), b) print() print("b.append(2)") b.append(2) # a與b的內容相同,地址有差異 print(id(a), a) print(id(b), b) print() # 內存地址相同嗎? # is 比較的是兩個對象的id值是否相等 print(a is b) print(id(a) == id(b)) # 內容相同嗎? print(a == b) print(a.__eq__(b)) if __name__ == '__main__': main()
/home/coder/anaconda3/envs/py37/bin/python /home/coder/PycharmProjects/Base/demo.py 140337952333704 [1, 2] 140337952333768 [1] b.append(2) 140337952333704 [1, 2] 140337952333768 [1, 2] False False True True Process finished with exit code 0
def __eq__(self, *args, **kwargs): # real signature unknown """ Return self==value. """ pass def id(*args, **kwargs): # real signature unknown """ Return the identity of an object. This is guaranteed to be unique among simultaneously existing objects. (CPython uses the object's memory address.) """ pass
https://www.jb51.net/article/131559.htmhtml
https://www.cnblogs.com/lilz/p/9410319.html#_label2python
https://www.cnblogs.com/wangkun122/p/9082088.htmlgit
Python具備開源、跨平臺、解釋型、交互式等特性,值得學習。
Python的設計哲學:優雅,明確,簡單。提倡用一種方法,最好是隻有一種方法來作一件事。
代碼的書寫要遵照規範,這樣有助於溝通和理解。
每種語言都有獨特的思想,初學者須要轉變思惟、踏實踐行、堅持積累。bash