```
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
>>>
```
- py转exe
- py服务器
- py登录
- py查询
- 爬TB热卖1017
- 爬TB分类1015
- 爬BD文库1010
- 爬文库924
- json917
- decode912
- 转码910
- radians829
- turtle827
- 画叶子820
- 树干815
- Turtle, mainloop718
- sorted716
- random711
- turtle.colormode709
- abs704
- begin_fill702
- randint,random627
- isalpha625
- keyword620
- compile618
- judge613
- list1.copy611
- random.choice606
- format_randint604
- save_csv528
- jieba523
- wordcloud521
- wordcloud516
- jieba.lcut514
- counts503
- format423
- 花瓣418
- strftime416
- turtle.fillcolor411
- random.random409
- pensize404
- 花蕊328
- input327
- eval_float320
- open319
- while314
- JCR影响因子313
- _to_chinese4_312
- encoding306
- read305
- flask1029