【问题标题】:How to make Transcrypt skip a line (without "try")?如何让 Transcrypt 跳过一行(没有“尝试”)?
【发布时间】:2021-10-07 00:12:40
【问题描述】:

我编写的程序应该能够直接通过解释器和 Transcrypt 运行。问题是当 Transcrypt 运行时我需要跳过一些行并且“try”在 Transcrypt 中不起作用。通过 Transcypt 运行程序时,还有其他方法可以跳过行吗?是否可以使用 if ?:

if transctypt 已激活:

提前致谢!

【问题讨论】:

标签: python transcrypt


【解决方案1】:

如果没有内置方法,你可能可以 e. G。寻找 document 变量的存在。不在浏览器中运行时应该没有这样的事情。 (我还没有测试过。)

try:
  assert document
  in_transcrypt = True
except Exception:
  in_transcrypt = False

【讨论】:

    【解决方案2】:

    感谢 fzzylogic 的评论,我解决了这样的问题:

    from org.transcrypt.stubs.browser import __pragma__
    
    #__pragma__('skip')
    import subprocess
    import os
    #__pragma__('noskip')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-15
      • 2021-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      相关资源
      最近更新 更多