Hello. I thought about receiving dictionary data from a Python program in AppleScript.
AppleScript
get do shell script "LANG=ja_JP.UTF-8 /usr/local/bin/python3 ~/dictdata.py"
set dictdata to run script result
get temperature of dictdata -- ==> "hot"
dictdata.py
# -*- coding: utf-8 -*-
dictdata = {'temperature': 'hot', 'humidity': '蒸しhot'}
str, first = "{", True
for k, v in dictdata.items():
if first:
first = False
else:
str += ", "
str += "%s: \"%s\"" % (k, v)
str += "}"
print(str)
Recommended Posts