eval

Calling the Javascript functions inside C# for a 64 bit project

感情迁移 提交于 2019-12-20 05:55:02
问题 I am trying to call the Javascript function "eval" from inside C# code (to utilise the string to operators parser). I used the following code: https://stackoverflow.com/a/12431435/712700 It crashes though with the following message--- : Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {0E59F1D5-1FBE-11D0-8FF2-00A0D10038BC} failed due to the following error: 80040154 Class not registered (Exception from HRESULT:

json数组对象和对象数组

三世轮回 提交于 2019-12-20 03:24:21
一、Json的简单介绍 从结构上看,所有的数据最终都可以分成三种类型: 第一种类型是scalar(标量),也就是一个单独的string(字符串)或数字(numbers),比如“北京”这个单独的词。 第二种类型是sequence(序列),也就是若干个相关的数据按照一定顺序并列在一起,又叫做array(数组)或List(列表),比如“北京,东京”。 第三种类型是mapping(映射),也就是一个名/值对(Name/value),即数据有一个名称,还有一个与之相对应的值,这又称作hash(散列)或dictionary(字典),比如“首都:北京”。 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,它的规则非常简单并且是 有趣 的: 1) 并列的数据之间用逗号(“,”)分隔。 2) 映射用冒号(“:”)表示。 3) 并列数据的集合(数组)用方括号("[]")表示。 4) 映射的集合(对象)用大括号(“{}”)表示。 按照这个规则可以作以下理解: 1.数组用“[]”创建,对象用“{}”创建,并且使用Json基本都是用[]或者{}创建的数组或对象,否则一个普通的字符串是没有意义的; 2.无论是数组还是对象,之间的元素都用“,”隔开; 3.对象内部,(属性的)名称和值用“:”隔开,并且必须要用“:”隔开,不可单独存在属性名或者值; 4

eval fails in list comprehension [duplicate]

怎甘沉沦 提交于 2019-12-20 02:12:57
问题 This question already has answers here : Python: How can I run eval() in the local scope of a function (2 answers) Closed 2 years ago . Consider the following hypothetical code: class B(object): def __init__(self): self.b = 2 def foo(self): out1 = [eval('self.b')] # ok print(out1) # prints: [2] out2 = [eval(cmd) for cmd in ['self.b']] # fails print(out2) # NameError: name 'self' is not defined b = B() b.foo() Why is the statement for out1 ok, but not for out2 , which gives the error "'self'

eval fails in list comprehension [duplicate]

谁说胖子不能爱 提交于 2019-12-20 02:11:59
问题 This question already has answers here : Python: How can I run eval() in the local scope of a function (2 answers) Closed 2 years ago . Consider the following hypothetical code: class B(object): def __init__(self): self.b = 2 def foo(self): out1 = [eval('self.b')] # ok print(out1) # prints: [2] out2 = [eval(cmd) for cmd in ['self.b']] # fails print(out2) # NameError: name 'self' is not defined b = B() b.foo() Why is the statement for out1 ok, but not for out2 , which gives the error "'self'

Evaluate a string as PHP code?

∥☆過路亽.° 提交于 2019-12-20 01:44:46
问题 I have a string that I want to have PHP read as a piece of code. The reason is that I want to build the set of instructions for PHP in advance, and then execute it later on. Currently I have: $string = '$this->model_db->get_results()'; And the desired result is: $string2 = $this->model_db->get_results(); 回答1: you can have a variable variable/function, but cannot have variable method chains. you can however create a method chain using variable variables/functions. Check this page of the php

Why does EcmaScript 5 strict mode go to such great lengths to restrict the identifier `eval`

冷暖自知 提交于 2019-12-20 00:24:51
问题 According to the spec (Annex C), strict-mode code can't do pretty much anything that might assign any identifier with the name eval . I can understand that one might want to restrict use of the actual eval function, but I don't see what purpose is served by restricting use of the name? 回答1: I can only speculate, but it seems to me that ES5-strict is saying that eval and arguments should be considered as raw syntax, not identifiers. It is reasonable that these two features should be

Why does EcmaScript 5 strict mode go to such great lengths to restrict the identifier `eval`

此生再无相见时 提交于 2019-12-20 00:23:01
问题 According to the spec (Annex C), strict-mode code can't do pretty much anything that might assign any identifier with the name eval . I can understand that one might want to restrict use of the actual eval function, but I don't see what purpose is served by restricting use of the name? 回答1: I can only speculate, but it seems to me that ES5-strict is saying that eval and arguments should be considered as raw syntax, not identifiers. It is reasonable that these two features should be

Semi-sandboxing Javascript eval

落花浮王杯 提交于 2019-12-19 19:56:41
问题 Background : I'm working on a framework/library to be used for a specific site in coordination with greasemonkey/userscripts. This framework/library will allow for addon support. The way it will work is an addon registers with the library listing required pages, resources, ectera and the library will wait until all critera is met to call the addon's load() function. The Issue :In this listing of 'required stuff' I want addon devs to be able to specify javascript(as string) to be evaluated as

python-基本操作

我的未来我决定 提交于 2019-12-19 11:09:27
实验课上所写 这主要有字符串处理和几个函数,来自教材上的代码 # 这是注释 ''' 这是多行注释 ''' ''' TempStr = input("请输入带有符号的温度值: ") if TempStr[-1] in ['F','f']: C = (eval(TempStr[0:-1]) - 32)/1.8 print("转换后的温度是{:.2f}C".format(C)) elif TempStr[-1] in ['C','c']: F = 1.8*eval(TempStr[0:-1]) + 32 print("转换后的温度是{:.2f}F".format(F)) else: print("输入格式错误") ''' ''' # 字符串的处理 str = "asdff" print(str[-1]) print(str[2]) ''' ''' # 同步赋值,交换变量 a=1 b=2 a,b=b,a print(a) print(b) ''' ''' # eval 函数:将表达式解析为可执行的字符串,包含字符串可用单引号引起 # 该函数允许内部家多余的空格,这些空格会被解释器忽略 print(eval("3*3")) print(eval("'hello'")) str="123456" print(eval(str[0:-1])) # 123456 val = eval(input(

How to dynamically execute/eval JavaScript code that contains an ES6 module / requires some dependencies?

霸气de小男生 提交于 2019-12-19 07:10:07
问题 I want my users to be able to use JavaScript as a scripting language inside my JavaScript application. In order to do so, I need to dynamically execute the source code. There seem to be two main options for dynamically executing JavaScript: a) Use eval(...) method ( or var func = new Function(...); ) . b) Add a <script> node to the DOM (for example by using $('body').append(...) ). Both methods work fine as long as I do not use any import statements in the dynamically executed source code. If