小编Ash*_*hes的帖子

Python打印属性没有__dict__

我在使用Python的脚本桥时遇到问题

我试图列出iTunes对象的属性

iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
Run Code Online (Sandbox Code Playgroud)

运用

>>> from pprint import pprint
>>> from Foundation import *
>>> from ScriptingBridge import *
>>> iTunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
>>> pprint (vars(iTunes))
Run Code Online (Sandbox Code Playgroud)

我回来了

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: vars() argument must have __dict__ attribute
Run Code Online (Sandbox Code Playgroud)

有谁知道怎么解决这个问题?

python scripting-bridge

10
推荐指数
2
解决办法
1万
查看次数

安装python autopy时出错

嘿,我在这里看了一下老问题,但它没有回答我的问题

我已经安装了libpng,然后尝试安装autopy并获得complie错误.

我不擅长python但所以我不确定如何修复它们.

Ashley:~ ashleyhughes$ sudo easy_install autopy
Searching for autopy
Reading http://pypi.python.org/simple/autopy/
Reading http://www.autopy.org
Best match: autopy 0.51
Downloading http://pypi.python.org/packages/source/a/autopy/autopy-0.51.tar.gz#md5=b92055aa2a3712a9c3b4c874014b450e
Processing autopy-0.51.tar.gz
Running autopy-0.51/setup.py -q bdist_egg --dist-dir /tmp/easy_install-U9uWoj/autopy-0.51/egg-dist-tmp-hdjtIx
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
src/screengrab.c:48:26: warning: implicit declaration of function
      'CGDisplayBitsPerPixel' is invalid in C99
      [-Wimplicit-function-declaration]
        bitsPerPixel = (uint8_t)CGDisplayBitsPerPixel(displayID);
                                ^ …
Run Code Online (Sandbox Code Playgroud)

python autopy

8
推荐指数
2
解决办法
4800
查看次数

Arduino和Bitwise,意外的结果

让我的自己在这里有点困惑.

我想测试一组位(3位)是否包含某个位置的位.

if (B110 & B010 == B010)
Run Code Online (Sandbox Code Playgroud)

(B110是要检查的数字,B010我想看的是否有)

上面的代码没有给我预期的结果,B110都是真的,B101是真的.我很确定我需要使用&(和)来测试掩码B010.

我的理解是B110和B010等于B010,B101和B010等于B000.但我的if语句是用两个测试位运行的吗?

我正在使用Arduino进行编码,我确信这对我来说是一个简单的误解,但不确定在哪里.

arduino

5
推荐指数
1
解决办法
627
查看次数

使用Serial.read()返回Arduino代码奇怪

在我的Arduino代码上遇到Serial.read()命令问题.我把它连接到两个连接到LED的74HC595移位寄存器.

我检查是否有串行数据,然后读取两个字节.然后将这些字节传递给一个将它们都移出的方法.当我使用Serial.print检查字节以将它们打印到串行监视器时,我得到了例如

49
255
50
255
Run Code Online (Sandbox Code Playgroud)

为什么我得到两个255's我已经阅读了arduino.cc上的文档,它说它只读取一个字节.有任何想法吗?

最终目标是读取串行线上的两个字节并将它们移出到移位寄存器IE是小数5和6的字节值通过第一个第3个LED将点亮一个移位寄存器然后第二个和第三个LED将在其他移位寄存器

const int dataPin = 8;
const int latchPin = 9;
const int clockPin = 10;

void setup() {
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) {
    byte low = Serial.read();
    byte high = Serial.read();
    Serial.println(low);
    Serial.println(high);
    sendBytes(low,high);
  }
}

void sendBytes(byte l, byte h) {
  digitalWrite(latchPin,LOW);
  shiftOut(dataPin,clockPin,MSBFIRST,l);
  shiftOut(dataPin,clockPin,MSBFIRST,h);
  digitalWrite(latchPin,HIGH);
}
Run Code Online (Sandbox Code Playgroud)

serial-port arduino

1
推荐指数
1
解决办法
5785
查看次数

标签 统计

arduino ×2

python ×2

autopy ×1

scripting-bridge ×1

serial-port ×1