Bonjour. J'ai pensé à recevoir des données de dictionnaire d'un programme Python dans 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 -- ==> "chaud"
dictdata.py
# -*- coding: utf-8 -*-
dictdata = {'temperature': 'chaud', 'humidity': '蒸しchaud'}
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