python - 执行脚本时出现 Python 错误
问题描述
我正在尝试使用 python 脚本控制 I/O 模块。我看到与未定义端口有关的错误。有任何想法吗?
我从以下链接中获取了代码
https://github.com/jkesanen/usbrly08/blob/master/usbrly08.py
谢谢。
更新
您好,感谢您的回复。我尝试使用添加的端口参数再次执行脚本。我现在看到一个不同的错误。我的中继模块连接到 com 端口 9。我在最初的帖子中添加了运行上述脚本后看到的错误。还有其他建议吗?谢谢
Microsoft Windows [版本 6.1.7601] 版权所有 (c) 2009 Microsoft Corporation。版权所有。
C:\Users\A1037648>cd \python
C:\Python>test.py -p9
Traceback (most recent call last):
File "C:\Python\Test.py", line 260, in <module>
main()
File "C:\Python\Test.py", line 217, in main
s = serial.Serial(args.port, timeout=args.timeout)
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 31, in
__init__
super(Serial, self).__init__(*args, **kwargs)
File "C:\Python27\lib\site-packages\serial\serialutil.py", line 240, in
__init__
self.open()
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 62, in
open
raise SerialException("could not open port {!r}:
{!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port '9': WindowsError(2,
'The system cannot find
the file specified.')
C:\Python>
解决方案
感谢您对此的帮助。我刚回来再次尝试它,它的工作原理!我附上了我用来控制 IO 模块的代码,如果有人觉得它有用的话。
echo[
cd..
timeout /t 1
cd..
timeout /t 1
cd..
timeout /t 1
cd python27
timeout /t 1
test.py -p com6 -n 0
推荐阅读
- reactjs - 如何让 command.js 和 index.d.ts 知道函数?
- android - 随着 Android Studio 4.1 更新 'Plugin incompatible with the new build found: Firebase Services' 出现警告信息
- angular - 与分页Angular一起过滤数据
- r - 如何用半一致的格式重命名观察?
- javascript - 使用 C# 到 JavaScript 的 UWP WebView 中 JSON 的问题无法正确读取
- c++ - 我可以在这个线性函数问题中使用什么算法?
- r - R中的辅助轴未注册
- java - 如何自动化 jprofiler 以保存具有不同参数的多个目标 java 程序的快照
- security - 为什么在认为不安全的情况下将 localhost 添加到 SAN 列表?
- python - python 3.9中的2 ^ 3 = 1怎么办