Pythonのバージョンがありません:3.5.2 numpyのバージョン:1.12.1numpyのfrombuffer - はAttributeError: 'str' はオブジェクトが属性 '__buffer__'
エラー:試しました
import numpy as np
s = 'Hello World'
np.frombuffer(s, dtype='S1')
AttributeError: 'str' object has no attribute '__buffer__'
もの:
を
- Tried Online Ideone compiler, got same error in Python3.xx.
- Referred scipy faqs for numpy and python compatible version, which states "NumPy support the Python 2.x series, (versions 2.6 and 2.7), as well as Python 3.2 and newer. The first release of NumPy to support Python 3 was NumPy 1.5.0."
同じ問題ではstackoverflowを試みましたが、何も見つかりませんでした。問題が見つからない可能性があります。 python3.xxでエラーとその解決方法を教えてください。 PY3セッションで
だから最初は私はああのようだった..それは単純なDtypeエラーです。私はそれを試した後、私はもっと頑張った。今私は不安がある。 – Scheme
文字列はバッファではありません。特に、py3では文字列がUnicodeではありません。どのような配列が欲しいですか?なぜあなたは 'frombuffer'を使用していますか?これは初心者のツールではありません。 – hpaulj
'frombuffer' docsにはこのような例がありますが、py3の使用のために洗練されている必要があります。 – hpaulj