小编Dar*_*nce的帖子

struct.unpack导致TypeError:'int'不支持缓冲区接口

我在Python 3.4中使用struct模块,如下所示:

length = struct.unpack('>B', data[34])[0]
Run Code Online (Sandbox Code Playgroud)

data 看起来像这样:

b'\x03\x01\x0e}GZ\xa8\x8e!\x1c\x7ft\xe8\xf9G\xbf\xb1\xdf\xbek\x8d\xb3\x05e~]N\x97\xad\xcaz\x03tP\x00\x00\x1eV\x00\xc0\n\xc0\t\xc0\x13\xc0\x14\xc0\x07\xc0\x11\x003\x002\x009\x00/\x005\x00\n\x00\x05\x00\x04\x01\x00\x00f\x00\x00\x00\x1b\x00\x19\x00\x00\x16parteek.khalsabani.com\xff\x01\x00\x01\x00\x00\n\x00\x08\x00\x06\x00\x17\x00\x18\x00\x19\x00\x0b\x00\x02\x01\x00\x00#\x00\x003t\x00\x00\x00\x10\x00\x1b\x00\x19\x08spdy/3.1\x06spdy/3\x08http/1.1\x00\x05\x00\x05\x01\x00\x00\x00\x00'
Run Code Online (Sandbox Code Playgroud)

我正进入(状态

TypeError:'int'不支持缓冲区接口.

我是使用struct的新手.怎么了?

python struct python-3.x

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

当组件更新值时,指令@Input 变量未得到更新

我正在尝试根据服务调用结果动态验证自定义文本输入。如果它是真的意味着 jumpyId 可以使用,否则显示错误。我现在的问题是当我从 fromEvent 更新 this.isAvailable 时,它​​没有反映自定义指令中的值。我期待如果 api 调用返回true,则指令应该接收true否则false

可用指令.ts

import { Directive, forwardRef, Input } from '@angular/core';
import { Validator, AbstractControl, NG_VALIDATORS } from '@angular/forms';
@Directive({
  selector: 'custom-text-input[vendorAvailable][formControlName],custom-text-input[vendorAvailable][formControl],custom-text-input[vendorAvailable][ngModel]',
  providers: [
    { provide: NG_VALIDATORS, useExisting: AvailabilityDirective, multi: true }
  ]
})
export class AvailabilityDirective implements Validator {

  @Input('available') available: boolean;
  validate(c: AbstractControl): { [key: string]: any } {
    console.log("valid", this.available);
    if (!this.available) {
      return {
        available: false
      };
    }
    return null;
  }
}
Run Code Online (Sandbox Code Playgroud)

事件观察: …

typescript angular-directive angular

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

为服务层选择哪个服务生命周期

尝试了解哪种服务生命周期最适合服务层瞬态或范围(为什么)。我正在寻找使用范围作为服务层而不是瞬态的优点和缺点。瞬态服务是否可以与数据库事务配合良好,或者将服务层保留在范围内并不是一件好事。谢谢

c# asp.net-core

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