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
标签:__,boy,dataclasses,python,示例,field,63 From: https://www.cnblogs.com/lovychen/p/18137081