为什么使用`pkg_resources.get_distribution`可以获得模块的版本?

时间:2019-04-24 18:00:30

标签: python

我已经阅读了一个python程序:

@Component({
  selector: 'ontime-course-form',
  templateUrl: './ontime-course-form.component.html',
  styleUrls: ['./ontime-course-form.component.scss']
})
export class OntimeCourseFormComponent {
  form = new FormGroup({
      topics: new FormArray([])
  })

  addTopic(topic: HTMLInputElement){
      this.topics.push(new FormControl(topic.value))
  }

  removeTopic(topic: FormControl){
    let index = this.topics.controls.indexOf(topic);
    this.topics.removeAt(index);
  }

  get topics(){
    return this.form.get('topics') as FormArray;
  }
}

我看不懂上面两行代码,怎么理解?

为什么使用import pkg_resources version = pkg_resources.get_distribution('shadowsocks').version 可以获取模块的版本?

0 个答案:

没有答案