学习Python中出现的错误集合(不定时更新)jupyter平台

 

 

 

 出现的问题:1、

  本图的错误,一个是line 7 init的两侧应该是是双下划线“__”导致所示错误

 2、

本图的错误是 line 12 Student.student_tatal+=1改为Student.student_total+=1

 输已经声明过的变量名的时候,可以用tab键

 

 

3、

解决:for后边加上冒号

 4、

 5、

原因:line42 应该改为  xiaoming=Student('xiaoming',22,'male')

 6、

为什么 line 30的 def check(self,):  #只要是对象的方法,都要以self开头   “ self, ”没加竟然没报错?

 

7、

原因:line 32 return 'you have'   ,   Student.pass_score-self.score   ,   'to achieve'   中的英文逗号容易忽略

8、

原因:while loop是字符串,要加" "

 9、没有输出结果

原因:line 26    return str1 应与if对其  使其跳出来   条件语句限制 了输入

 10、

 

 为什么没达到预期的效果?

 11、

原因:上下两部分几乎都一样,但是上面是中括号,下面是小括号,所以上面成功,下面失败

 12、

  编码错误,尽管前面可能已经加了 utf-8  有可能是平台Python2版本与Python3版本编码问题

 13、这个是没错,但是数据如何加载进来的呢?疑惑中。。。

 

14、

words_df=pd.DataFrame({'segment':segment})
#words_df.head()
stopwords=pd.read_csv("data/stopwords.txt",index_col=False,quoting=3,sep="\t",names=['stopword'], encoding='utf-8')#quoting=3全不引用
#stopwords.head()
words_df=words_df[~words_df.segment.isin(stopwords.stopword)]

 出现的错误: '>' not supported between instances of 'float' and 'str'

 

 

posted @ 2018-02-08 21:48  谦曰盛  阅读(271)  评论(0编辑  收藏  举报