import numpy as np
import pandas as pd
from pandas import Series,DataFrame
1. 语法错误 SyntaxError :
原因:一般都是符号问题 ,如漏 符号或者出现中文符号
dict_city = {
‘shanghai’:{2019:54000 ,2020:56000},
‘beijing’ :{2018:66666 ,2019:77777}
}
df_city = DataFrame(dict_city)
df_city
2.属性错误 AttributeError:
原因,读取对象不存在属性 或者 使用不存在的函数
a = 2
print(a.name)
a.append(3)
a = 2
print(a.name)
a.append(3)
coding:utf-8
s =“883823782738”
print(s)
np.close()
3. 索引错误 IndexError :
原因: 读取的索引超出对象的索引范围
list1 = [1,2]
print(list1[3])
list1 = [1,2]
print(list1[3])
4 .键值错误 KeyError
原因: 读取字典不存在的key