#!/usr/bin/env python
# -*- coding:utf-8 -*-
str="test"
print(ascii(str))
a=bytearray("asdff",encoding='utf-8')
print(a)
b=bytearray(10)
print(b)
c=bytearray([1,1,3,6])
print(c)
d=complex("1+2j")
print(d)
a1="3*5+9"
a=compile(a1,'','eval')
print(eval(a))
print(a1)
py="print('this is a string')"
result=exec(py)
print(result)
x = 10
expr = """
z = 30
sum = x + y + z
print(sum)
"""
def func():
y = 20
exec(expr)
exec(expr, {'x': 1, 'y': 2})
exec(expr, {'x': 1, 'y': 2}, {'y': 3, 'z': 4})
func()
转载于:https://www.cnblogs.com/NiceTime/p/10085333.html