我已经阅读了一个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
可以获取模块的版本?