Python Plotdevice,将json值转换为变量
Python Plotdevice,将json值转换为变量,python,json,Python,Json,我有以下代码: size(297,420) weather = read("january_2016.json", dict=adict) print "(in january 2016 the min temperature was %i)" % weather.MaxTemperature.min r = "%i" %weather.MaxTemperature.min nofill() stroke(.1) print r oval(10,10,r,r) 但我这里有两个问题: 1.
我有以下代码:
size(297,420)
weather = read("january_2016.json", dict=adict)
print "(in january 2016 the min temperature was %i)" % weather.MaxTemperature.min
r = "%i" %weather.MaxTemperature.min
nofill()
stroke(.1)
print r
oval(10,10,r,r)
但我这里有两个问题:1.当我想使用oval(10,10,
r,r
)时,我得到以下错误:DeviceError: Invalid coordinates (looking for ['Point', 'Size'], got ['Point', 'str', 'str'])
二,。如何将椭圆的锚定居中谁能帮我?提前感谢您
oval()
需要4个数字
oval(x, y, width, height, plot=True, **style)
但是你有这条线
r = "%i" % weather.MaxTemperature.min
它导致r
成为str
(字符串类型,而不是数字类型)
为什么不直接尝试r=weather.MaxTemperature.min
,因为它可能是一个数字
r = weather.MaxTemperature.min
# or if that value isn't numeric, try converting it to a float
# r = float(r)
...
oval(10, 10, r, r)
oval()
需要4个数字
oval(x, y, width, height, plot=True, **style)
但是你有这条线
r = "%i" % weather.MaxTemperature.min
它导致r
成为str
(字符串类型,而不是数字类型)
为什么不直接尝试r=weather.MaxTemperature.min
,因为它可能是一个数字
r = weather.MaxTemperature.min
# or if that value isn't numeric, try converting it to a float
# r = float(r)
...
oval(10, 10, r, r)