我真的想知道Visual Studio代码中是否有一些扩展或其他可以帮助识别和删除任何未使用的导入的方法。
我有很多像这样的进口产品,它已接近40行。我知道其中一些没有使用,问题是安全地删除它们。
from django.core.mail import EmailMultiAlternatives, send_mail
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from rest_framework import routers, serializers, viewsets, status
from rest_framework.views import APIView
from rest_framework.response import Response
from django.contrib.auth.models import User
转到用户设置json文件并添加以下内容:
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--enable=W0614"
]
这应该自动删除未使用的python导入。
更多建议:How can I check for unused import in many Python files?