我有以下代码,但我不喜欢get
语句的样子。是否有可能以某种方式将其移至单独的方法中?
我想让一种方法更具可读性。
params = get_news_params_validator.document
keywords = params.get('keywords')
statuses = params.get('status')
sources = params.get('source')
from_time = params.get('from_time')
to_time = params.get('to_time')
offset = params.get('offset')
limit = params.get('limit')
query = SearchQuery(
statuses=statuses, sources=sources, text=keywords, from_time=from_time, to_time=to_time)
items = await self._news_feed_service.search(query=query, limit=limit, offset=offset)