Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.chararray.byteswap

chararray.byteswap(inplace)

Swap the bytes of the array elements

Toggle between low-endian and big-endian data representation byreturning a byteswapped array, optionally swapped in-place.

Parameters:

inplace : bool, optional

IfTrue, swap bytes in-place, default isFalse.

Returns:

out : ndarray

The byteswapped array. Ifinplace isTrue, this isa view to self.

Examples

>>>A=np.array([1,256,8755],dtype=np.int16)>>>map(hex,A)['0x1', '0x100', '0x2233']>>>A.byteswap(True)array([  256,     1, 13090], dtype=int16)>>>map(hex,A)['0x100', '0x1', '0x3322']

Arrays of strings are not swapped

>>>A=np.array(['ceg','fac'])>>>A.byteswap()array(['ceg', 'fac'],      dtype='|S3')
  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp