Python學習記錄之語法(一)

2021-08-21 06:20:51 字數 685 閱讀 6500

1.from...import         import...as的意思

from os import makedirs, unlink, sep   #從os包中引入 makedirs.unlink,sep類

from os.path import dirname, exists, isdir, splitext  從 os包中的path類中引入 dirmame exists 等方法

import urllib.request   //引入 urllib resquest包

from urllib.parse import urlparse 

from sys import argv 

import html.parser as h   #給包html.parser 定義乙個h別名

2.輸出系統當前時間、

import

datetime

asdt #給detetime包定義乙個別名 dt

print(dt.datetime.now())

3.urllib2.urlopen()的使用,用來從網上獲取資訊。

在python3中urllib和urllib2

集合乙個包了,就是urllib.request包。

import urllib.request

resp=urllib.request.urlopen("")

Python 學習筆記之語法(一)

python對語法格式要求很嚴格,因此,在編寫時一定要注意這些問題,比如下面就是這樣的問題 traceback most recent call last file line 1,in file d anzhuang anaconda lib site packages spyderlib widg...

Python學習筆記一之基礎語法

python是一種解釋性 意味著開發過程沒有編譯環節,相對於編譯性語言而言 物件導向 動態資料型別的高階程式語言。識別符號 第乙個字元必須是字母表中的字母或下劃線 識別符號的其它部分由字母 數字和下劃線組成。識別符號區分大小寫。python3允許使用中文作為變數名,非ascii碼識別符號也是允許的。...

學習python 語法(一)

1 通過下標遍歷tuple list dict vowels aejouy for i in powerful if i in vowels print i words cool powerful readable for i in range 0,len words print i,words i...