我使用
用pip安装了kivi,pyjnius和jniuslet jsonData = [{
"fName": "John",
"lname": "Smith"
},{
"fName": "Jane",
"lname": "hardy"
}];
let api_name = "fName";
jsonData.forEach((data)=>{
data.newName= data[api_name];
delete data[api_name];
})
console.log(jsonData);
它已成功构建并安装。
我试图运行其中一个kivy的例子:
python.exe -m pip install pyjnius
python.exe -m pip install jnius
并收到错误:
'''
Compass example
This example is a demonstration of Hardware class usage.
But it has severals drawbacks, like using only the magnetic sensor, and
extrapolating values to get the orientation. The compass is absolutely not
accurate.
The right way would be to get the accelerometer + magnetic, and computer
everything according to the phone orientation. This is not the purpose of
this
example right now.
You can compile it with::
./build.py --package org.test.compass --name compass \
--private ~/code/kivy/examples/android/compass \
--window --version 1.0 debug installd
'''
import kivy
kivy.require('1.7.0')
from jnius import autoclass
from kivy.app import App
from kivy.properties import NumericProperty
from kivy.clock import Clock
from kivy.vector import Vector
from kivy.animation import Animation
Hardware = autoclass('org.renpy.android.Hardware')
class CompassApp(App):
.
.
.
我做错了什么?我是kivy的新手,只是试图让它在给定的例子上工作。也许我需要在运行之前编译它?
答案 0 :(得分:0)
我不确定你的pyjnius是否编译正确。但是,更大的问题是你的pyjnius代码只适用于Android - org.renpy.android.Hardware在桌面上不存在。
这通常是pyjnius的情况,虽然它可以在桌面上工作但如果你只需要Android就没有多大意义。我通常只有在Android上运行才有条件地导入和使用pyjnius来解决这个问题。