企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
``` Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> eval <built-in function eval> >>> help(eval) Help on built-in function eval in module builtins: eval(source, globals=None, locals=None, /) Evaluate the given source in the context of globals and locals. The source may be a string representing a Python expression or a code object as returned by compile(). The globals must be a dictionary and locals can be any mapping, defaulting to the current globals and locals. If only globals is given, locals defaults to it. >>> eval('1.2+3.4') 4.6 >>> a = '1.2+3.4' >>> type(a) <class 'str'> >>> eval(a) 4.6 >>> print(a) 1.2+3.4 >>> input('输入算式:') 输入算式:1.2+3.4 '1.2+3.4' >>> eval(input('请输入算式:') ) 请输入算式: Traceback (most recent call last): File "<pyshell#16>", line 1, in <module> eval(input('请输入算式:') File "<string>", line 0 SyntaxError: unexpected EOF while parsing >>> eval(input('请输入算式:')) 请输入算式:1.2+5.6 6.8 >>> >>> eval(input('请输入算式:')) 请输入算式:2.5+6.5 9.0 >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) 123:123*741589654100 91215527454300 >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) 123:123*741589654100 91215527454300 >>> SyntaxError: invalid syntax >>> >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) 123:123*741589654100 91215527454300 >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) SyntaxError: invalid syntax >>> >>> eval <built-in function eval> >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) 123:123*741589654100 91215527454300 >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) SyntaxError: invalid syntax >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) 123:123*741589654100 91215527454300 >>> >>> eval(input('请输入算式:')) 请输入算式:5*8 40 >>> eval(input('请输入算式:')) 请输入算式:6*3 18 >>> eval(input('请输入算式:')) 请输入算式:888*999 887112 >>> ok Traceback (most recent call last): File "<pyshell#23>", line 1, in <module> ok NameError: name 'ok' is not defined >>> >>> >>> eval(input('123:')) SyntaxError: invalid syntax >>> ``` ``` Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> n ='他是一个学生的’ SyntaxError: EOL while scanning string literal >>> n ='他是一个学生的' >>> for i in n: print(i) 他 是 一 个 学 生 的 >>> n ='他是一个学生的' >>> for i in n: print(i) 他 是 一 个 学 生 的 >>> n = 4 . 5 SyntaxError: invalid syntax >>> n = 4.5 SyntaxError: unexpected indent >>> .............................................n = 4...5 SyntaxError: invalid syntax >>> ............................. SyntaxError: invalid syntax >>> n = 4.5 >>> n 4.5 >>> int(n) 4 >>> float(n) 4.5 >>> n = float(input(':')) :5.5 >>> n 5.5 >>> n = int(input(':')) :5.6 Traceback (most recent call last): File "<pyshell#18>", line 1, in <module> n = int(input(':')) ValueError: invalid literal for int() with base 10: '5.6' >>> n = float(input(':')) :5.7 >>> N Traceback (most recent call last): File "<pyshell#20>", line 1, in <module> N NameError: name 'N' is not defined >>> n 5.7 >>> ```