Receive dictionary data from a Python program in AppleScript

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

Receive dictionary data from a Python program in AppleScript
Create a dictionary in Python
Get data from Quandl in Python
When writing a program in Python
A Python program that aggregates time usage from icalendar data
Receive textual data from mysql with python
Write a Caesar cipher program in Python
Hash in Perl is a dictionary in Python
Read a file in Python with a relative path from the program
Generate a class from a string in Python
Receive and display HTML form data in Python
A program that removes duplicate statements in Python
Generate a MeCab dictionary from Nico Nico Pedia data
Data analysis in Python: A note about line_profiler
A simple Pub / Sub program note in Python
Call a Python script from Embedded Python in C ++ / C ++
Create a datetime object from a string in Python (Python 3.3)
A well-prepared record of data analysis in Python
I made a Caesar cryptographic program in Python.
Extract data from a web page with Python
I made a prime number generation program in Python
Write a super simple molecular dynamics program in python
Output the time from the time the program was started in python
Try embedding Python in a C ++ program with pybind11
Get data from GPS module at 10Hz in Python
From buying a computer to running a program with python
Until you insert data into a spreadsheet in Python
I made a prime number generation program in Python 2
A Python program that converts ical data into text
Generate Word Cloud from case law data in python3
Get the value of a specific key in a list from the dictionary type in the list with Python
Python2 / numpy> Replace only a specific column in a file with column data from another file> numpy.c_
Predict from various data in Python using Facebook Prophet, a time series prediction tool
Take a screenshot in Python
Handle Ambient data in Python
Create a function in Python
Display UTM-30LX data in Python
OCR from PDF in Python
Receive runtime arguments in Python 2.7
A memo to generate a dynamic variable of class from dictionary data (dict) that has only standard type data in Python3
Make a bookmarklet in Python
Avoid KeyError in python dictionary
Draw a heart in Python
A memo that reads data from dashDB with Python & Spark
A Python program in "A book that gently teaches difficult programming"
A general-purpose program that formats Linux command strings in python
How to slice a block multiple array from a multiple array in Python
Published a library that hides character data in Python images
How to run a Python program from within a shell script
I tried "a program that removes duplicate statements in Python"
[python] Manage functions in a dictionary (command table, function table, function pointer)
Python: Create a dictionary from a list of keys and values
Hit REST in Python to get data from New Relic
[Python] Use JSON format data as a dictionary type object
Just try to receive a webhook in ngrok and python
Get Leap Motion data in Python.
Maybe in a python (original title: Maybe in Python)
Write a binary search in Python
Call a Python function from p5.js.
Create an instance of a predefined class from a string in Python
Python: Exclude tags from html data