python学习笔记--list

python3 -V 显示python版本。


使用idle来完成实验代码,有提示等多项功能。


alt+p前一条指令
alt+n后一条指令


chapters=["list",'share your code','file and except','storage',
 'handle data','class','web develop','mobile application',
 'handle input','real web develop','handle complexity',
 'others']
print (chapters)


列表最后项加逗号不会默认生成一个空值而是会直接忽略掉


python的变量标识符没有类型,也就是列表里可以嵌套列表。


访问列表数据
print (chapters[0])


查看列表方法
help(list)
pop有返回值


chapters=['1',"list",
 '2','share your code',
 '3','file and except',
 '4','storage',
 '5','handle data',
 '6','class',
 '7','web develop',
 '8','mobile application',
 '9','handle input',
 '10','real web develop',
 '11','handle complexity',
 '12','others']


迭代
for each in chapters:
print(each)


nested lists:
chapters=[
 ['1',"list"],
 ['2','share your code'],
 ['3','file and except'],
 ['4','storage'],
 ['5','handle data'],
 ['6','class'],
 ['7','web develop'],
 ['8','mobile application'],
 ['9','handle input'],
 ['10','real web develop'],
 ['11','handle complexity'],
 ['12','others']
 ]

print(chapters[0][1])

chapters=["python",
 ['1',"list"],
 ['2','share your code'],
 ['3','file and except'],
 ['4','storage'],
 ['5','handle data'],
 ['6','class'],
 ['7','web develop'],
 ['8','mobile application'],
 ['9','handle input'],
 ['10','real web develop'],
 ['11','handle complexity'],
 ['12','others']
 ]


for each in chapters:
print(each)

for each in chapters:
if isinstance(each,list):
for each in each:
print(each)
else:
print(each)

查看bif:

dir(__builtins__)

bif=built in function 


help(dir)


dir(...)
    dir([object]) -> list of strings
    
    If called without an argument, return the names in the current scope.
    Else, return an alphabetized list of names comprising (some of) the attribut


创建函数:

def print_hello(arg):
print("hello"+arg)

def print_x_y():
print("x""y")










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值