需求格式:GET /users/:user/repos

程序:

 1 class Chain(object):
 2     def __init__(self,path=''):
 3         self._path=path
 4 
 5     def __getattr__(self, path):
 6         return Chain( '%s/%s' %(self._path,path))
 7 
 8     def __str__(self):
 9         return self._path
10 
11     def __call__(self, user):
12         return Chain('%s/%s' %(self._path,user))
13 
14     __repr__=__str__

实例:

1 print('GET',Chain().users('michael').repos)
2 print('GET',Chain().status.user.timeline.list)

结果:

1 GET /users/michael/repos
2 GET /status/user/timeline/list

相关文章:

  • 2021-06-01
  • 2022-02-01
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
猜你喜欢
  • 2021-09-25
  • 2021-11-14
  • 2021-06-09
  • 2021-12-23
  • 2022-01-03
  • 2021-12-22
  • 2021-11-26
相关资源
相似解决方案