Skip to content
This repository was archived by the owner on Nov 29, 2023. It is now read-only.

Commit 34974db

Browse files
dizcologydanoscarmike
authored andcommitted
fix python2 print unicode issue [(#2183)](GoogleCloudPlatform/python-docs-samples#2183)
1 parent ddc2534 commit 34974db

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

samples/analyze/beta_snippets.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def track_objects_gcs(gcs_uri):
206206

207207
# Get only the first annotation for demo purposes.
208208
object_annotation = object_annotations[0]
209-
print('Entity description: {}'.format(
209+
# description is in Unicode
210+
print(u'Entity description: {}'.format(
210211
object_annotation.entity.description))
211212
if object_annotation.entity.entity_id:
212213
print('Entity id: {}'.format(object_annotation.entity.entity_id))
@@ -259,7 +260,8 @@ def track_objects(path):
259260

260261
# Get only the first annotation for demo purposes.
261262
object_annotation = object_annotations[0]
262-
print('Entity description: {}'.format(
263+
# description is in Unicode
264+
print(u'Entity description: {}'.format(
263265
object_annotation.entity.description))
264266
if object_annotation.entity.entity_id:
265267
print('Entity id: {}'.format(object_annotation.entity.entity_id))
@@ -343,7 +345,8 @@ def stream_generator():
343345
description = annotation.entity.description
344346
# Every annotation has only one frame
345347
confidence = annotation.frames[0].confidence
346-
print('\t{} (confidence: {})'.format(description, confidence))
348+
# description is in Unicode
349+
print(u'\t{} (confidence: {})'.format(description, confidence))
347350
# [END video_streaming_label_detection_beta]
348351

349352

@@ -463,7 +466,8 @@ def stream_generator():
463466
# track_id tracks the same object in the video.
464467
track_id = annotation.track_id
465468

466-
print('\tEntity description: {}'.format(description))
469+
# description is in Unicode
470+
print(u'\tEntity description: {}'.format(description))
467471
print('\tTrack Id: {}'.format(track_id))
468472
if annotation.entity.entity_id:
469473
print('\tEntity id: {}'.format(annotation.entity.entity_id))

0 commit comments

Comments
 (0)