python基礎之基礎資料型別1

2022-04-04 02:51:36 字數 456 閱讀 2801

int 整形

十進位制二進位制轉換方法

在整形中不是 0 的數字就是布林值就為真

在布林值中,true 為1(int) fslse 為 0 (int)

字串中只要不是空就是ture, 有乙個空格也是ture

str(true),str(false) 得出的都是字串

字串步長

字串方法

is系類

- name.isdigit() 判斷字串中是不是全是數字

- name.isdecimal() 判斷是不是十進位制 name = "123"

- name.isalnum()判斷是不是數字字母中文

- name.isalpha() 判斷是不是字母中文

- name.isupper()

- name.islower()

for 迴圈

可迭代物件

Python基礎之資料型別

1.程式輸出 print print hello world hello world 2.程式輸入 input name input shuaishuai print hello name hello shuaishuai 3.注釋 這是乙個注釋 這是 乙個多行注釋 4,運算子 加,減,乘除,地板除...

python 基礎之資料型別

一.變數 1.目的 為了能讓計算機能像人一樣記憶 2.使用 先定義 後引用 定義 1.變數名 變數值 2.變數值 記錄事物的狀態 記憶體位址 id是通過記憶體位址算出來的 age 18 print id age 1374973952 型別type print type age is 判斷id是否相等...

Python基礎之資料型別

1.bool 在python裡面哪些值是false 0 none false t true print type t 2.int i 123 print type i 3.float 1e10 科學計數法也是float 字串是不可改變的,字串做了一些操作後,會生成乙個新的字串 只有乙個元素的tupl...