Python/Django: How to remove extra white spaces & tabs from a string?

后端 未结 6 2113
天命终不由人
天命终不由人 2020-12-29 21:59

I\'m building a website with Python/Django. Users submit tags. Each tag can contain multiple words. Each tag has an ID number. I want to make sure tags that are formatted sl

6条回答
  •  孤城傲影
    2020-12-29 22:57

    I would use Django's slugify method, which condenses spaces into a single dash and other helpful features:

    from django.template.defaultfilters import slugify
    

提交回复
热议问题