W3cubDocs

/TensorFlow 2.4

tf.strings.bytes_split

Split string elements of input into bytes.

Examples:

tf.strings.bytes_split('hello').numpy()
array([b'h', b'e', b'l', b'l', b'o'], dtype=object)
tf.strings.bytes_split(['hello', '123'])
<tf.RaggedTensor [[b'h', b'e', b'l', b'l', b'o'], [b'1', b'2', b'3']]>

Note that this op splits strings into bytes, not unicode characters. To split strings into unicode characters, use tf.strings.unicode_split.

See also: tf.io.decode_raw, tf.strings.split, tf.strings.unicode_split.

Args
input A string Tensor or RaggedTensor: the strings to split. Must have a statically known rank (N).
name A name for the operation (optional).
Returns
A RaggedTensor of rank N+1: the bytes that make up the source strings.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/strings/bytes_split