-*- coding:utf-8 -*-


if 判斷


ipython3

if "name" in mame:

   print\(""\)

尋找元素裡面內容


ipython3

if "name" not in name:

   print\(""\)

如果沒有可以添加



elif 多項


else 結束


input輸入


int(input


print 輸出

name = "ben"

hi = 18

print("hi裡面的數值是:%d"%hi)

print("名字是:%s"%name)


while 循環


\t \n


import random

random.randint


import


ipython3裡

a = 100

b = 3.14

c = "laowang"

可以在ipython3使用指令type(a)(b)(c)來查看類型


python3列表:

添加新元素

name = ["一","二","三"]

name.append(name) 增加元素在最後


name.insert(1,"name") 元素插隊意思


name2 = ["四","五","六"]

name3 =name+name2

name3 =["一","二","三","四","五","六"]


extend()

name.extend(name2) 指定將元素name2匯入元素name


刪除元素

name.pop()刪除最後一個.....括號內可以指令位置

name.remove()根據內容刪除

name.del xxx[下標]#根據下標刪除


元素修改:

name[下標] = "name"

results matching ""

    No results matching ""