I keep getting 'invalid character in identifier' when opening a file in python

后端 未结 1 924
-上瘾入骨i
-上瘾入骨i 2021-01-14 18:44

So I\'m trying to open a file with the following code:

open(‘datapickle’, ‘rb’) as f: 
  names, F, approximate = pickle.load(f)

However, I

相关标签:
1条回答
  • 2021-01-14 18:58

    Two problems:

    1. Those tick characters are not valid. Use single ' or double " quotes.

    2. The correct syntax is with open(...) as f. You're missing the with statement.

    The editor you're using should be highlighting your text in different colors to help you with this. If you don't have an editor that can do this, try downloading Sublime Text or Atom.

    0 讨论(0)
提交回复
热议问题