I am trying to execute a simple python code on z/OS USS. The code was working fine until I added code to assign values to a dictionary. When I run my code, it displays unprintable characters in the output at the code location where I assign a value to the dictionary. ie., in line d[“Alias”] = line[0:4]
It appears that square brackets ‘[’ are not valid. When I run the same code in my workstation using pycharm editor, it runs fine. So, I am not sure what the issue is. Can anyone help me to resolve this issue ?
d = {}
file1 = open(inp_file_path,“r”)
line = file1.readline().strip()
while line!="":
d[“Alias”] = line[0:4]
jsonstr = json.dumps(d)
line = file1.readline.strip()
file1.close()
print(jsonstr)
Here is the output in the job:
File “/u/test/python/pyfilr.py”, line 15
dï…"Alias"ï… = lineï…0:4ï…
¬
SyntaxError: invalid syntax