python (63):dataclasses 简单示例
dataclasses 简单示例:
import transformers from dataclasses import dataclass,field import argparse @dataclass class Person(): age: int = field(default=10) Name: str = field(default="Tom") high: int = field( default=185, metadata={ "help": "people high." }, ) boy: bool = False if __name__ == "__main__": parser = transformers.HfArgumentParser( (Person) ) ( PerSon, ) = parser.parse_args_into_dataclasses() print(PerSon.boy)
>>>python file.py
>>>False
>>>python file.py --boy
>>>True