当前位置: 首页 > news >正文

VScode python插件

1.LiveCode

从扩展商店安装完以后初次使用可能异常
要配置一下解释器的路径
设置(ctrl+,)-> 搜索 Livecode:Python Path
然后填解释器的路径


如果我们有循环或需要展示一些中间变量状态,就可以使用该插件,LiveCode主要拥有下面四个功能

实时评估:不需要运行Python脚本就可以查看各个变量的值

变量显示:每当声明或更改一个变量时,它的新值都会同时改变并显示

2在 VS Code 调试器中自动显示变量形状和维度信息

原文在这里

win下

C:\Users\<你的用户名>\.vscode\extensions\ms-python.debugpy-<版本号>-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_xml.py

linux下

~/.vscode/extensions/ms-python.debugpy-*\bundled\libs\debugpy\_vendored\pydevd\pydevd_plugins\extensions\types/

修改 get_variable_details() 函数
打开 pydevd_xml.py 文件,找到get_variable_details()函数,完整修改之后如下

def get_variable_details(val, evaluate_full_value=True, to_string=None, context: Optional[str] = None): """ :param context: This is the context in which the variable is being requested. Valid values: "watch", "repl", "hover", "clipboard" """ try: # This should be faster than isinstance (but we have to protect against not having a '__class__' attribute). is_exception_on_eval = val.__class__ == ExceptionOnEvaluate except: is_exception_on_eval = False if is_exception_on_eval: v = val.result else: v = val _type, type_name, resolver = get_type(v) type_qualifier = getattr(_type, "__module__", "") if not evaluate_full_value: value = DEFAULT_VALUE else: try: # 添加形状信息 shape_info = "" try: # 处理 PyTorch Tensor if type_qualifier == "torch" and hasattr_checked(v, 'shape') and hasattr_checked(v, 'dtype'): shape = tuple(v.shape) dtype = str(v.dtype) shape_info = f"{{Tensor: {shape}}} " # 处理 NumPy ndarray elif type_qualifier == "numpy" and hasattr_checked(v, 'shape') and hasattr_checked(v, 'dtype'): shape = tuple(v.shape) dtype = str(v.dtype) shape_info = f"{{ndarray: {shape}}} " # 处理 Pandas DataFrame elif type_qualifier == "pandas.core.frame" and hasattr_checked(v, 'shape'): shape = tuple(v.shape) shape_info = f"{{DataFrame: {shape}}} " # 处理 Pandas Series elif type_qualifier == "pandas.core.series" and hasattr_checked(v, 'shape'): shape = tuple(v.shape) dtype = str(v.dtype) shape_info = f"{{Series: {shape}}} " # 处理其他有 shape 属性的对象 elif hasattr_checked(v, 'shape'): shape_info = f"{{{v.shape}}} " # 处理可计数对象 elif hasattr_checked(v, '__len__'): try: length = len(v) # 对于字符串类型,只显示 {str} 而不显示长度 if type_name == "str": shape_info = f"{{{type_name}}} " else: shape_info = f"{{{type_name}: {length}}} " except: pass except: pass str_from_provider = _str_from_providers(v, _type, type_name, context) if str_from_provider is not None: value = shape_info + str_from_provider elif to_string is not None: value = shape_info + to_string(v) elif hasattr_checked(v, "__class__"): if v.__class__ == frame_type: value = pydevd_resolver.frameResolver.get_frame_name(v) elif v.__class__ in (list, tuple): if len(v) > 300: value = "%s: %s" % (str(v.__class__), "<Too big to print. Len: %s>" % (len(v),)) else: value = "%s: %s" % (str(v.__class__), v) else: try: cName = str(v.__class__) if cName.find(".") != -1: cName = cName.split(".")[-1] elif cName.find("'") != -1: # does not have '.' (could be something like <type 'int'>) cName = cName[cName.index("'") + 1 :] if cName.endswith("'>"): cName = cName[:-2] except: cName = str(v.__class__) value = "%s: %s" % (cName, v) else: value = shape_info + str(v) except: try: value = repr(v) except: value = "Unable to get repr for %s" % v.__class__ # fix to work with unicode values try: if value.__class__ == bytes: value = value.decode("utf-8", "replace") except TypeError: pass return type_name, type_qualifier, is_exception_on_eval, resolver, value

再重启即可

3 Better Comments

写注释的好帮手
它能根据关键词用不同的颜色高亮代码片段。支持以下类型的高亮:

感叹号 “!” 代码警告。
问号“?”代表存留疑问。
TODO 代码未来将要进行的操作。
@param 参数

此外,它还支持在设置中自定义需要高亮句子的首部关键词。

4 autoDocstring

写注释的好帮手
能够自动生成函数的注释格式,通过tab键快速切换填充块编写相应的注释。

Python Indent

python 自动缩进

http://www.jsqmd.com/news/234845/

相关文章:

  • 工厂人员定位软件系统从场景分级与技术选型、系统架构到核心功能详解(一)
  • 喜报!美创5款产品入选《数据安全产品目录(2025年版)》
  • 如何选择靠谱的IP购买渠道?这几点务必注意
  • 深度测评10个AI论文写作软件,本科生轻松搞定毕业论文!
  • 小学常识让2300年都无人能识的“更无理”直线一下子浮出水面推翻直线公理
  • 从图文对齐到端侧部署|AutoGLM-Phone-9B多模态优化全链路
  • 做私域流量运营的第5年,我终于不用凌晨2点还在P图了
  • AI万能分类器实战:10分钟部署完成商品分类
  • 基于FDA药物警戒数据库的阿培利斯相关不良事件安全信号评估
  • 中文情感分析实战|基于StructBERT镜像快速部署WebUI与API
  • StructBERT情感分析镜像详解|附Python BERT实践对比案例
  • 轻量高效多模态模型落地指南|基于AutoGLM-Phone-9B的技术演进
  • 云原生部署(AWS/Azure)
  • 除了 Perfdog,如何在 Windows 环境中完成 iOS App 的性能测试工作
  • 只有 Flutter IPA 文件,通过多工具组合完成有效混淆与保护
  • 10分钟实现中文情感分析|基于StructBERT镜像快速部署
  • 中文情感分析技术难点与落地|StructBERT模型镜像全解析
  • StructBERT中文情感分析镜像发布|开箱即用,支持WebUI与API调用
  • 一句话理解pyside6的信号和槽机制
  • 如何高效做中文情感分析?试试这款集成WebUI的StructBERT镜像
  • 中文情感分析实战|基于StructBERT轻量级镜像快速部署
  • 中国高校屠榜2026 CSRankings!上交清华并列第一,北大AI封神
  • IP静态是什么意思?静态IP适用于哪些业务场景?
  • 科研党必备PDF利器|PDF-Extract-Kit镜像实现布局检测与公式识别一体化
  • 微服务分布式SpringBoot+Vue+Springcloud的美团餐饮商户点评管理与数据分析系统_
  • 何时我们才能完全相信纯视觉APP自动化测试?
  • 没技术背景也能用:AI分类器云端版,鼠标点击就运行
  • HY-MT1.5-7B大模型深度应用|打造专业级法律翻译系统
  • 35.轴承滚珠检测
  • 零代码玩转AI分类:预置镜像直接调用,不懂Python也能用