On 02/03/2016 09:03 PM, 阎兆珣 wrote:
a = input("tell me which py to execute: ")
print(a)
print('import '+a)
print(type('import'+a))
eval('print(a)')
Eval is meant to evaluate Python expressions. The import is a
statement, not an expression. Also, it's a bad idea to use e
On Thu, Feb 4, 2016 at 4:03 PM, 阎兆珣 wrote:
>a = input("tell me which py to execute: ")
>
>print(a)
>
>print('import '+a)
>
>print(type('import'+a))
>
>eval('print(a)')
>
>try:
>
>eval('import '+a)
>
>except Exception as e:
>
>print('Error: ', e)
>
>
a = input("tell me which py to execute: ")
print(a)
print('import '+a)
print(type('import'+a))
eval('print(a)')
try:
eval('import '+a)
except Exception as e:
print('Error: ', e)
##while True:
## pass
@python 3.4.2
this code attempts to