たとえば、これは私のコードです:
#extract the object from "lastringa.pickle" and save it
extracted = ""
with open("lastringa.pickle","rb") as f:
extracted = pickle.load(f)
「lasting.pickle」には、テキストを含む文字列オブジェクトが含まれています。
したがってextracted.
、ファイルを開く前に入力すると、図に示すようなコードの提案を取得できます。
しかし、この操作の後extracted = pickle.load(f)
、入力extracted.
してもコードの提案は表示されなくなります。
誰かが私にそれがなぜであり、これを解決する方法を説明できますか?
Pickleは、オブジェクトをバイナリファイルとして読み書きします。これopen('lastringa.pickle', 'rb')
は、rb
オプションを使用しているコマンド、つまりバイナリの読み取りによって確認できます。
Your IDE doesn't know the type of the object that the pickle is expected to read, so that it can suggest the string methods (e.g. .split()
, .read()
)
On the other hand, in the first photo, your IDE knows that expected
is a string and it knows what to suggest.
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加