NNsr
NNsr

Reputation: 1063

Unicode error in Python 3

I am trying to set a folder path as follows:

folderpath = "C:\\Users\NY1\\Dropbox\\Research ideas\\Final Code\\Poject_name"

and I am getting the following error:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 9-10: malformed \N character escape

What am I doing wrong?

Upvotes: -1

Views: 9576

Answers (2)

john2195
john2195

Reputation: 1

I used ("C:\Users\JOHN-PC\Videos\ml-twitter-sentiment-analysis-develop\data\twittertrain.csv"). to remove this problem. you have \ before users and c.s.v file name .

Upvotes: 0

grovesNL
grovesNL

Reputation: 6075

You are not escaping one of the backslashes (before NY1):

folderpath = "C:\\Users\NY1\\Dropbox\\Research ideas\\Final Code\\Poject_name"

...should be:

folderpath = "C:\\Users\\NY1\\Dropbox\\Research ideas\\Final Code\\Poject_name"

Notice that the exception is telling you the location of where this character occurs (position 9-10).

Upvotes: 2

Related Questions