python出现invalid argument什么意思_python程序运行后提示IOError: [Errno 22] Invalid argument 急啊!!!!...
程序如下:importfcntlimportosimporttimefromstructimport*#ConstantsINPUT='0'OUTPUT='1'PWM_FREQ=520#Pinnumberdir_pin=2pwm_pin=3pwm_value=255#FilelocationsMODE_FILE='/sys/de...
程序如下:
import fcntl
import os
import time
from struct import *
# Constants
INPUT = '0'
OUTPUT = '1'
PWM_FREQ = 520
# Pin number
dir_pin = 2
pwm_pin = 3
pwm_value = 255
# File locations
MODE_FILE = '/sys/devices/virtual/misc/gpio/mode/gpio' + str(dir_pin)
PIN_FILE = '/sys/devices/virtual/misc/gpio/pin/gpio' + str(dir_pin)
PWM_FILE = '/dev/pwmtimer'
# Pin mode
os.system('echo ' + OUTPUT + ' > ' + MODE_FILE)
# Configure PWM
with open(PWM_FILE, 'wb') as f:
pwm_struct = pack('iiiI', pwm_pin, 0, 0, PWM_FREQ)
fcntl.ioctl(f, 0xfa, pwm_struct)
# Motor control
def drive_motor(dir, pwm):
# Set direction
os.system('echo ' + str(dir) + ' > ' + PIN_FILE)
# Output PWM to motor
with open(PWM_FILE, 'wb') as f:
pwm_struct = pack('ii', pwm_pin, pwm)
fcntl.ioctl(f, 0x19, pwm_struct)
# Do stuff with the motor
drive_motor(0, 0)
time.sleep(1)
drive_motor(0, 200)
time.sleep(2)
drive_motor(0, 0)
time.sleep(0.5)
drive_motor(1, 255)
time.sleep(2)
drive_motor(0, 0)
展开
python出现invalid argument什么意思_python程序运行后提示IOError: [Errno 22] Invalid argument 急啊!!!!...相关推荐
- python在windows command下打印中文出错 IOError [Errno 22] Invalid argument
问题描述: python版本:2.7.15 pycharm的python版本:2.7.15 python文件编码:utf-8 windows command编码已经通过执行chcp 65001改为了u ...
- python保存创建文件报错 with open(fileName,‘w‘) as fp: IOError: [Errno 22] invalid mode (‘w‘) or filename
原因:python2.7保存文件时文件名中含有中文 改为:fileName.decode('utf-8')即可 with open(fileName.decode('utf-8'),'w') as f ...
- PythonIOError: [Errno 22] invalid mode ('r') or filename
每次我们需要指导一个文件具体路径得时候,有一部分人喜欢直接用windows得右键文件->属性->安全信息,然后粘贴复制,如下图: 在有一些编辑器看起来时没有任何问题,如下图: 然后运行就会 ...
- 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’
如题,在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: '文件路径',在查阅了大量资料后也得到了一些解决方案,但是这些解决方案 ...
- Python OSError: [Errno 22] Invalid argument:的出现和解决
1.在学习从文件读取数据中,写了个示例代码,读取不在同一个目录的file.txt,运行后报这个Python OSError: [Errno 22] Invalid argument:错误: (1).首 ...
- python中遇到报错OSError: [Errno 22] Invalid argument的解决方法
将时间戳用python语言转换成指定日期: 代码如下: import timetimeStamp = 1589018284000 timeArray = time.localtime(timeStam ...
- python在使用绝对路径时出现OSError: [Errno 22] Invalid argument: ‘E:\python\python扩展\text_file\pi_digits.txt
今天我在练习python文件的绝对路径时发现OSError: [Errno 22] Invalid argument: 'E:\python\python扩展\text_file\pi_digits. ...
- Python错误集锦:打开文件路径提示参数无效,OSError: [Errno 22] Invalid argument: ‘D:\juzicode\桔子code\readme.txt’
原文链接:http://www.juzicode.com/archives/2493 错误提示: 打开文件路径提示参数无效:OSError: [Errno 22] Invalid argument: ...
- python中invalid argument_Python创建文件报错OSError:[Errno 22] Invalid argument处理
问题: windows平台下使用python open函数w模式打开文件报错"OSError: [Errno 22] Invalid argument: '../news/"消费升 ...
最新文章
- C++中STL中的大、小、相等概念
- Nginx http和反向代理配置实例介绍
- vb 搜索指定目录下的指定类型文件
- 【简易教程】基于Vue-cli使用eslint指南
- ASP.NET Core quot;完整发布,自带运行时quot; 到jexus
- 函数:MySQL中字符串匹配函数LOCATE和POSITION使用方法
- *p++和*++p_2020年P气瓶充装新版试题及P气瓶充装找答案
- 电子计算机发展为第五代,电子计算机的发展历程是怎样的?
- 超详细汇总21个mysql优化实践【收藏版MySQL优化】
- 【学习笔记】深入理解js原型和闭包(13)——【作用域】和【上下文环境】
- 基于php和服务器推技术的web即时聊天系统,基于php和服务器推技术的Web即时聊天系统-计算机系统应用.PDF...
- 使用ffmpeg对视频、音频进行分离
- Citrix 桌面云 XenApp_XenDesktop_7.18 部署
- 自定义Qml控件:ImageButton
- 彻底卸载VS2015
- 用户访谈与问卷调查怎么做
- 【算法】生成n个互异随机数的初步算法
- 实验二 Linux下Vi编辑器的使用
- java多个文件压缩打包成zip下载
- 智课雅思词汇---二十五、-ate