python-3.x - 错误:需要以下参数:主机
问题描述
试图在python中可视化各种传感器数据的结果
我可以像 linux 命令一样在 raspberry pi 终端上看到它python Sensortag2650.py -n 5 -t 1 -T -A -H -M -B -G -K -L -P 54:6C:0E:52:F8:FC
现在我想在 python shell 上用相同的代码看到相同的结果
def main():
import time
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('host', action='store',help='MAC of BT device')
parser.add_argument('-n', action='store', dest='count', default=0,
type=int, help="Number of times to loop data")
parser.add_argument('-t',action='store',type=float, default=5.0, help='time between polling')
parser.add_argument('-T','--temperature', action="store_true",default=False)
parser.add_argument('-A','--accelerometer', action='store_true',
default=False)
parser.add_argument('-H','--humidity', action='store_true', default=False)
parser.add_argument('-M','--magnetometer', action='store_true',
default=False)
parser.add_argument('-B','--barometer', action='store_true', default=False)
parser.add_argument('-G','--gyroscope', action='store_true', default=False)
parser.add_argument('-K','--keypress', action='store_true', default=False)
parser.add_argument('-L','--light', action='store_true', default=False)
parser.add_argument('-P','--battery', action='store_true', default=False)
parser.add_argument('--all', action='store_true', default=False)
arg = parser.parse_args(sys.argv[1:])
print('Connecting to ' + arg.host)
tag = SensorTag(arg.host)
输出 :
Sensortag2650.py [-h] [-n COUNT] [-t T] [-T] [-A] [-H] [-M] [-B] [-G]
[-K] [-L] [-P] [--all]
host
Sensortag2650.py: `error: the following arguments are required: host`
解决方案
推荐阅读
- javascript - Bootstrap carousel slide.bs.carousel 或 slid.bs.carousel 事件未使用 Angular 触发
- haskell - 为什么是 * -> * 类型的列表?
- git - git commit does not find path on linux windows subsystem (WSL)
- mysql - 带有 MySql 数据库的 Flutter List View Builder 项目计数数据表
- flutter - 如何在颤动中保存 qrimage?
- php - Failed to load resource: the server responded with a status of 500 (Internal Server Error) |php Mysql
- installation - 如何在实习生运行 bat 文件的 wix 中运行 VBS 脚本
- drools - Optaplanner 终止属性未按给定时间工作
- c++ - 具有不同底层 STL 容器的两个类如何呈现相同的迭代器接口?
- batch-file - 为什么这段代码不显示我设置的 5 个随机标题?