exec的问题 [英] problem with exec

查看:79
本文介绍了exec的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我的程序阅读并翻译此代码后:


koristi os,sys;

ispisi''bok kaj ima'';


进入:


import os,sys;

打印''bok kaj ima'';


当它使用exec运行此代码时,我总是得到这样的错误,但是我

还不知道是什么问题:


Traceback(最近一次调用最后一次):

文件" C:\Python24 \ Lib \ site-packages \VL \ ___ ___。py,188行,

kompajlati

kompajlati_proces()

档案" C:\Python24 \Lib\site-packages \VL \ ___ ___。py",第183行,在

kompajlati_proces

h2 = Konzola()

文件C:\Python24 \Lib\site-packages \VL \ ___ ___。py,第158行,在__init__

k = kod(ZTextCtrl .GetLabel())

文件C:\Python24 \ Li b\site-packages\VL\__init __。py",第83行,in kod

exec(str_ngh)

文件"< string>" ,第1行

import os,sys;

^

语法错误:语法无效


PS :当用户使用我的程序编写脚本时他怎么能改变他不需要

吸取他的源代码行

例如

import os,sys

n = 90

if n == 90:print" OK"

else:print" No"

问候,


Vedran

__________________________________________________ ________________ Vedran

veki ICQ#:264412055当前ICQ状态: +更多与我联系的方式获取ICQ!

__________________________________________________ ________________

Hello,

After my program read and translate this code:

koristi os,sys;
ispisi ''bok kaj ima'';

into the:

import os,sys;
print ''bok kaj ima'';

and when it run this code with "exec", I always get error like this, but I
still dont''t know what is a problem:

Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 188, in
kompajlati
kompajlati_proces()
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 183, in
kompajlati_proces
h2=Konzola()
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 158, in __init__
k=kod(ZTextCtrl.GetLabel())
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 83, in kod
exec(str_ngh)
File "<string>", line 1
import os ,sys ;
^
SyntaxError: invalid syntax

PS: How can I change when user write script with my program to he don''t need
aspirate the lines of his source code
e.g.
import os,sys
n=90
if n==90:print "OK"
else:print "No"
Regards,

Vedran
__________________________________________________ ________________ Vedran
veki ICQ#: 264412055 Current ICQ status: + More ways to contact me Get ICQ!
__________________________________________________ ________________


推荐答案

.. .. ::: JA ::: ...写道:
....:::JA:::... wrote:

你好,


我的程序读完之后翻译这段代码:


koristi os,sys;

ispisi''bok kaj ima'';


进入:


导入os,sys;

打印''bok kaj ima'';


和当它使用exec运行此代码时,我总是得到这样的错误,但是我还是b $ b仍然不知道是什么问题:


回溯(最近一次调用最后一次):

文件C:\Python24 \Lib\site-packages \VL \ ___ ___。py,第188行,
kompajlati

kompajlati_proces()

文件" C:\Python24 \Lib\site-packages \VL \ ___ ___。py" ,第183行,在

kompajlati_proces

h2 = Konzola()

文件C:\Python24 \Lib\site- packages\VL\__init __。py",第158行,在__init__

k = kod(ZTextCtrl.GetLabel())

文件C:\Python24 \\ \\Lib\site-packages\VL\__in它__。py",第83行,in kod

exec(str_ngh)

文件"< string>",第1行

import os,sys;

^

语法错误:语法无效
Hello,

After my program read and translate this code:

koristi os,sys;
ispisi ''bok kaj ima'';

into the:

import os,sys;
print ''bok kaj ima'';

and when it run this code with "exec", I always get error like this, but I
still dont''t know what is a problem:

Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 188, in
kompajlati
kompajlati_proces()
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 183, in
kompajlati_proces
h2=Konzola()
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 158, in __init__
k=kod(ZTextCtrl.GetLabel())
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 83, in kod
exec(str_ngh)
File "<string>", line 1
import os ,sys ;
^
SyntaxError: invalid syntax



这几乎可以肯定是因为代码包含嵌入式运输

返回:

This is almost certainly because the code contains embedded carriage
returns:


>> code = """ import os,sys; \ nprint''bok kaj ima'';"""
exec code
>>code = """import os,sys;\nprint ''bok kaj ima'';"""
exec code



bok kaj ima

bok kaj ima


>> code =" ;"" import os,sys; \\ nnprint''bok kaj ima'';"""
exec code
>>code = """import os,sys;\r\nprint ''bok kaj ima'';"""
exec code



Traceback(最近一次调用最后一次):

文件"< s tdin>",第1行,在< module>

文件"< string>",第1行

import os,sys;

^

语法错误:语法无效

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
import os,sys;
^
SyntaxError: invalid syntax


> ;>>
>>>


PS:当用户使用我的程序编写脚本时他怎么能改变他不需要

吸取他的源代码行

例如

import os,sys

n = 90

如果n == 90:打印OK

else:print" No"

PS: How can I change when user write script with my program to he don''t need
aspirate the lines of his source code
e.g.
import os,sys
n=90
if n==90:print "OK"
else:print "No"



我'恐怕我不明白这个问题。如果你在谈论

代码的缩进,如果你不想缩进,你将有

来使用大括号 - {和} - 来表示嵌套你的节目结构。


问候

史蒂夫

-

Steve Holden +1 571 484 6266 +1 800 494 3119

Holden Web LLC / Ltd http:// www.holdenweb.com

Skype:holdenweb http://del.icio.us/steve.holden

--------------- Asciimercial --------- ---------

上网:博客,镜头和互联网标签

许多服务目前提供免费注册

-----------感谢您阅读-------------

I''m afraid I don''t understand this question. If you are talking about
the indentation of the code, if you don''t want indentation you will have
to use braces - { and } - to indicate the nesting structure of your program.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------


周六,2007年7月21日16:31:38 -0400,Steve Holden写道:
On Sat, 21 Jul 2007 16:31:38 -0400, Steve Holden wrote:

我很害怕我不明白这个问题。如果你在谈论

代码的缩进,如果你不想缩进,你将有

来使用大括号 - {和} - 来表示嵌套你的程序结构。
I''m afraid I don''t understand this question. If you are talking about
the indentation of the code, if you don''t want indentation you will have
to use braces - { and } - to indicate the nesting structure of your program.



哦,我这样戏弄n00bs并不好。你知道Python没有

使用大括号,它使用BEGIN ... END块。

-

史蒂文。

Oh my, teasing the n00bs like that is not nice. You know Python doesn''t
uses braces, it uses BEGIN ... END blocks.
--
Steven.


21 srp,22:31,Steve Holden< st ... @ holdenweb.comwrote:
On 21 srp, 22:31, Steve Holden <st...@holdenweb.comwrote:

... ::: JA ::: ...写道:
...:::JA:::... wrote:

你好,
Hello,


我的程序阅读并翻译此代码后:
After my program read and translate this code:


koristi os,sys;

ispisi' 'bok kaj ima'';
koristi os,sys;
ispisi ''bok kaj ima'';


进入:
into the:


import os,sys;

print''bok kaj ima'';
import os,sys;
print ''bok kaj ima'';


当它用exec运行此代码时,我总是得到这样的错误,但是我还是b $ b b不知道是什么问题:
and when it run this code with "exec", I always get error like this, but I
still dont''t know what is a problem:


Traceback(最近一次调用最后一次):

文件" C :\ Python24 \Lib\site-packages \VL \ ___ ___。py",188行,in

kompajlati

kompajlati_proces()

文件C:\Python24 \Lib\site-packages \VL \ ___ ___。py,第183行,

kompajlati_proces

h2 = Konzola()

文件C:\Python24 \Lib\site-packages \VL \ ___ ___。py,第158行,在__init__

k = kod(ZTextCtrl.GetLabel())

文件C:\Python24 \Lib\site-packages \VL \ ____。py。,第83行,in kod

exec(str_ngh)

文件"< string& gt;",第1行

import os,sys;

^

语法错误:语法无效
Traceback (most recent call last):
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 188, in
kompajlati
kompajlati_proces()
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 183, in
kompajlati_proces
h2=Konzola()
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 158, in __init__
k=kod(ZTextCtrl.GetLabel())
File "C:\Python24\Lib\site-packages\VL\__init__.py", line 83, in kod
exec(str_ngh)
File "<string>", line 1
import os ,sys ;
^
SyntaxError: invalid syntax



这几乎可以肯定是因为代码包含嵌入式运输

返回:


This is almost certainly because the code contains embedded carriage
returns:


>> code =""" import os,sys; \ nprint''bok kaj ima'';"""

>> exec code
>>code = """import os,sys;\nprint ''bok kaj ima'';"""
>>exec code



bok kaj ima

bok kaj ima


>> code =""" import os,sys; \\ nnprint''bok kaj ima'';"""

>> exec code
>>code = """import os,sys;\r\nprint ''bok kaj ima'';"""
>>exec code



Traceback(最近一次调用最后一次):

文件"< stdin>",第1行,< module> ;

文件"< string>",第1行

import os,sys;

^

语法错误:语法无效

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
import os,sys;
^
SyntaxError: invalid syntax


>>>
>>>


PS:当用户使用我的程序编写脚本时他怎么能改变他不需要

吸取他的源代码行

例如

import os,sys

n = 90

如果n == 90:打印OK

else:print" No"
PS: How can I change when user write script with my program to he don''t need
aspirate the lines of his source code
e.g.
import os,sys
n=90
if n==90:print "OK"
else:print "No"



我怕我不明白这个问题。如果你在谈论

代码的缩进,如果你不想缩进,你将有

来使用大括号 - {和} - 来表示嵌套你的节目结构。


问候

史蒂夫

-

Steve Holden +1 571 484 6266 +1 800 494 3119

Holden Web LLC / Ltd http:// www.holdenweb.com

Skype:holdenweb http://del.icio.us/steve.holden

--------------- Asciimercial --------- ---------

上网:博客,镜头和互联网标签

许多服务目前提供免费注册

-----------感谢您阅读-------------


I''m afraid I don''t understand this question. If you are talking about
the indentation of the code, if you don''t want indentation you will have
to use braces - { and } - to indicate the nesting structure of your program.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------



你好,


感谢以前的所有事情,但我只想问代码

缩进,这与{和}有关n'n

就业,这是我的例子我如何解决这个代码

缩进:

Hello,

Thanks for everything previously, but just to I ask about code
indentation,this with { and } doesn''t
employed, here is my example how can I solve this about code
indentation:


>> n = 90
如果n == 90:
>>n=90
if n==90:



{print" bok kjai ma''}

文件"< input>",第2行

{print" bok kjai ma''}

^

语法错误:语法无效

谢谢!!!!!!!


问候,Vedran

{print "bok kjai ma''}
File "<input>", line 2
{print "bok kjai ma''}
^
SyntaxError: invalid syntax
Thanks!!!!!!!

Regards,Vedran


这篇关于exec的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆