基本資料型別

2021-10-06 12:21:40 字數 1812 閱讀 7265

2 識別符號

3 基本資料型別

變數5 字串

表示式分類:算術表示式、邏輯表示式

表示式特點:

語句的執行一般會對程式產生一定的影響,在互動模式中不一定會輸出語句的執行結果

建立目的:專門用來完成特定的功能

函式分類:

函式的兩要素:

返回值:

命名方式:

下劃線命名法:用下劃線「_」來連線所有單詞,如get_url,buffer_size

s1 =

["hellow "

,"world"

]s3 = s1

s2 = s1

print(id

(s1),id

(s2),id

(s3)

)# 2157165469952 2157165469952 2157165469952

print

(s1==s2==s3)

# true

import copy

s4 = copy.deepcopy(s1)

print

(s4)

# ['hellow ', 'world']

rint(

id(s1),id

(s4)

)# 2157165469952 2157166222656

print

(s4==s1)

# true

s1 =

["hellow "

,"world"

]s3 = s1

s2 = s1

print(id

(s1),id

(s2),id

(s3)

)print

(s1==s2==s3)

s1 =

["hellow "

,"python"

]# s1 重新賦值

print(id

(s1),id

(s2),id

(s3)

)# 結果:1952879090432 1952879075648 1952879075648

# 對s1重新賦值,改變了s1指向的 記憶體位址,但不改變s2,s3指向的記憶體位址

(拓展資料:python中字串的用法(後附加轉義字元表))

#''' '''三個單引號對宣告的字串,會保留其格式

string1=

''' 1.a&**

2.b *(*

3.c4.d #%$6

'''print

(string1)

'''結果:

1.a&**

2.b *(*

3.c4.d #%$6

'''string2=

""" 1.../..

2..../.

3.,[...

4..&&&..

"""print

([string2]

)'''結果:

['\n 1.../..\n 2..../.\n 3.,[...\n 4..&&&..\n '

]

基本資料型別

列舉 定義列舉型別 enum season 定義兩個列舉變數 enum season mylove yourlove 為兩個列舉變數賦值 yourlove fall mylove winter 把列舉值當成無符號整數執行輸出 nslog fall 的值 u fall 3 nslog winter 的...

基本資料型別

建立資料庫 create database database name 顯示所有資料庫 show databases 選擇使用那個資料庫 use database name 刪除資料庫 drop database database name 檢視自己mysql資料庫支援什麼儲存引擎 show eng...

基本資料型別

整型int 整數,在目前絕大多數機器上佔4個位元組。tc環境中是2個位元組 單精度實型float 單精度浮點數,一般是4個位元組長 雙精度實型double 雙精度浮點數,一般是8個位元組長 字元型char 字元,一般是1個位元組長 用來表示256個ascii字元,或者0 255的整數 列舉型enum...