Python: How to detect debug interpreter

前端 未结 3 1280
悲&欢浪女
悲&欢浪女 2021-01-04 09:09

How can I detect in my python script if its being run by the debug interpreter (ie python_d.exe rather than python.exe)? I need to change the paths to some dlls that I pass

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-04 09:34

    An easy way, if you don't mind relying on the file name:

    if sys.executable.endswith("_d.exe"):
      print "running on debug interpreter"
    

    You can read more about the sys module and its various facilities here.

提交回复
热议问题