Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用这样的请求参数:
filter_tiles=01,21,30
如何将值转换为 Django 中的字符串列表?
我用这个:
filter_tiles = filter(len, map(str, request.POST.get('filter_tiles', '').split(',')))
虽然不喜欢。
见下面的代码:
import urlparse urlparse.parse_qs('filter_tiles=01,21,30')
{'filter_tiles': ['01,21,30']}#输出
{'filter_tiles': ['01,21,30']}
现在您可以像访问任何其他字典一样访问它。