简体   繁体   English

意外的续行符

[英]unexpected line continuation character

i am learning how to do data science and was following the kaggle tutorial for titanic .我正在学习如何进行数据科学,并正在关注泰坦尼克号kaggle 教程

However,然而,

women_only_stats = data[                          \ #Which element           
                     (data[0::,4] == "female")    \ #is a female
                   &(data[0::,2].astype(np.float) \ #and was ith class
                         == i+1) \                       
                   &(data[0:,9].astype(np.float)  \#was greater 
                        >= j*fare_bracket_size)   \#than this bin              
                   &(data[0:,9].astype(np.float)  \#and less than
                        < (j+1)*fare_bracket_size)\#the next bin    
                      , 1]                        #in the 2nd col                           

I got this error on the first line of (data[0::,4] == "female")我在(data[0::,4] == "female")的第一行收到此错误

Error:错误:

SyntaxError: unexpected character after line continuation character SyntaxError:行继续符后的意外字符

Your code (and the code on the website you copied from) has backslashes followed by comments.您的代码(以及您复制的网站上的代码)带有反斜杠,后跟注释。 Eg例如

\ #is a female

The backslash is the "line continuation character".反斜杠是“行继续符”。 The error is telling you you shouldn't have a line continuation character followed by more text (in this case a comment).该错误告诉您不应该在行继续符后跟更多文本(在本例中为注释)。

Take out the backslashes.去掉反斜杠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM