1.names=['a','b']
>>> isinstance(names,list)
True
>>> names=2
>>> isinstance(names,list)
False
isinstance(x,y) 可以判断x是否是类型y。
2.这个版本可以继续想(page 30)
movies=["a","b","c","d",["f",["g","h"]]]
print(movies[4])
for each_item in movies:
count=0
if isinstance(each_item,list):
while(count<len(each_item)):
while isinstance(each_item,list):
each_item=each_item[count]
count=count+1
print(each_item)
else:
print(each_item)
3.注释用""".....""",即三个引号。
4.page 76
print(data.readline(),end='')
SyntaxError: invalid syntax
5.从文件中读取每一行
data=open("F://results.txt")
for e in data:
print(e)
data.close()
6.page86
python的非为 not
9.page 89教你如何处理异常。暂时跳过。记得补上。
if not e.find==-1: