1. 程式人生 > >phthon入門介紹

phthon入門介紹

ada alt col python爬蟲 初學者 一個 cas 應用程序 ase

1.基本的python語法

2.python爬蟲

3.基本的數據分析

4.做網站

5.做機器學習

1.python簡介:

Python 是一種解釋型語言: 這意味著開發過程中沒有了編譯這個環節。類似於PHP和Perl語言。

Python 是交互式語言: 這意味著,您可以在一個Python提示符,直接互動執行寫你的程序。

Python 是面向對象語言: 這意味著Python支持面向對象的風格或代碼封裝在對象的編程技術。

Python 是初學者的語言:Python 對初級程序員而言,是一種偉大的語言,它支持廣泛的應用程序開發,從簡單的文字處理到 WWW 瀏覽器再到遊戲。

2.python基本的打印語句

(0)import this 引入python贊美之歌

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren
t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it Although that way may not be obvious at first unless you
re Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, its a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- lets do more of those!

(2)打印基本的語句:python2.x需要對漢字進行utf‘-8編碼,3.x不用

Python中默認的編碼格式是 ASCII 格式,在沒修改編碼格式時無法正確打印漢字,所以在讀取中文時會報錯。

解決方法為只要在文件開頭加入 # -*- coding: UTF-8 -*- 或者 #coding=utf-8 就行了(註意:#coding=utf-8 的 = 號兩邊不要空格。)


註意:Python3.X 源碼文件默認使用utf-8編碼,所以可以正常解析中文,無需指定 UTF-8 編碼。

註意:如果你使用編輯器,同時需要設置 py 文件存儲的格式為 UTF-8,否則會出現類似以下錯誤信息:

打印單條語句:

>>> print("hello,word")
hello,word
>>> print("你好世界")
你好世界

打印多條語句(一行多條語句需要用分號隔開)

>>> print("hello,word");print("你好,世界")
hello,word
你好,世界

phthon入門介紹