cancel
Showing results for 
Search instead for 
Did you mean: 

SAP DataHub Pipeline Python 3.6 decode Error

wjdwlgh888
Discoverer
0 Kudos
248

1. Operator

2. Pipeline

3. Result(Error)

4. Question

Why is there a decode error?
And what is the solution

Below is the code.
The question is simple.
How should I print out korean?
I've tried most of what Google has found, but I failed.

#code

#coding=utf-8
result = "한글 출력 테스트"
result = result.decode('utf8').encode('utf8')
api.send("outstr", result)

Accepted Solutions (0)

Answers (1)

Answers (1)

Vitaliy-R
Developer Advocate
Developer Advocate

As far as I know in Python3 all strings are already Unicode. So if I run simple

result = "한글 출력 테스트"
api.send("outstr", result)

with

I am getting a result in Wiretap

Here is a complete graph JSON, if you want to run the same:

{
	"properties": {},
	"description": "Encode Korean",
	"processes": {
		"python3operator1": {
			"component": "com.sap.system.python3Operator",
			"metadata": {
				"label": "Python3Operator",
				"x": 12,
				"y": 12,
				"height": 80,
				"width": 120,
				"extensible": true,
				"config": {
					"script": "result = '한글 출력 테스트'\napi.send(\"outstr\", result)"
				},
				"additionaloutports": [
					{
						"name": "outstr",
						"type": "string"
					},
					{
						"name": "outblob",
						"type": "blob"
					}
				]
			}
		},
		"wiretap1": {
			"component": "com.sap.util.wiretap",
			"metadata": {
				"label": "Wiretap",
				"x": 196.99999904632568,
				"y": 12,
				"height": 80,
				"width": 120,
				"ui": "dynpath",
				"config": {}
			}
		}
	},
	"groups": [],
	"connections": [
		{
			"metadata": {
				"points": "136,43 163.99999952316284,43 163.99999952316284,52 191.99999904632568,52"
			},
			"src": {
				"port": "outstr",
				"process": "python3operator1"
			},
			"tgt": {
				"port": "in",
				"process": "wiretap1"
			}
		}
	],
	"inports": {},
	"outports": {}
}