简体   繁体   English

使用 python 在我的计算机和我的 android 手机之间共享 bool 值的最佳方式是什么?

[英]What is the best way for me to share bool values between my computer and my android phone using python?

For my project I am trying to have my Android phone take pictures of lights that are powered by my computer.对于我的项目,我试图让我的 Android 手机拍摄由我的计算机供电的灯的照片。 I am doing this through an app I am building with Kivy.我正在通过与 Kivy 一起构建的应用程序来执行此操作。 What I need to do is to for multiple lights is the following:我需要做的是为多个灯如下:

Android: Ask for light (x) to be turned on Computer: Turn light (x) on Android: Take photo and tell computer photo has been taken Computer: Turn light (x) off ... Android:要求打开灯 (x) 计算机:打开 Android 上的灯 (x):拍照并告诉计算机照片已拍摄 计算机:关闭灯 (x) ...

If I were to do this all on one computer I would make the status of the light a bool value (ex. lightOn == True) and would just check if it is True of False.如果我要在一台计算机上完成所有这些操作,我会将灯的状态设为布尔值(例如 lightOn == True),并且只检查它是否为 True 或 False。

What is the best way for me to share the status of the light between my computer and my android phone?在我的电脑和我的 android 手机之间共享灯状态的最佳方式是什么?

One way to achieve that is to use sockets, create a socket connection between the computer and your android device and then change the boolean values on given command passed through the socket connection socket tutorial .实现这一点的一种方法是使用套接字,在计算机和您的 android 设备之间创建一个套接字连接,然后更改通过套接字连接套接字教程传递的给定命令的布尔值。 one other solution not very optimal is to use an API the values will be set by the android application and the requests will be made from the computer, for this case I recommend flask-restful, it's really an easy way to create the API you'll need, flask-restful docs另一种不是很理想的解决方案是使用 API,这些值将由 android 应用程序设置,请求将从计算机发出,在这种情况下,我建议使用 Flask-restful,这确实是一种创建 API 的简单方法。我需要, flask-restful 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在同一台计算机上运行的Python软件之间进行通信的最佳方式是什么? - What is the best way to communicate between Python softwares running on the same computer? 你能给我一种分享我的python程序的方法吗? - Can you give me a way to share my python's program? 在多个Python进程之间共享字典的最佳方法是什么? - What's the best way to share a dictionary between multiple Python processes? 在我的Python脚本中,在模块之间共享记录器实例的惯用方法是什么? - What is the idiomatic way to share a logger instance between modules in my Python script? 我收集模拟结果的最佳方式是什么? - What is the best way for me to gather my simulation results? 使用python从计算机上的应用程序中提取值 - Using python to pull values from an application on my computer 在python中用数据制作数组的最佳方法是什么? - What is the best way make an array out of my data in python? 在线监控python脚本的进度,或在我的手机上,或另一台计算机上 - Monitoring the progress of a python script online, or on my phone, or another computer 使用tkinter按钮更新布尔值的最佳方法是什么? - What would be the best way to update my boolean using tkinter buttons? 在我的开发计算机和树莓派之间同步python文件 - Synchronize python files between my development computer and my raspberry
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM