本文介绍了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 Istill dont''t know what is a problem: Traceback (most recent call last):File "C:\Python24\Lib\site-packages\VL\__init__.py", line 188, inkompajlatikompajlati_proces()File "C:\Python24\Lib\site-packages\VL\__init__.py", line 183, inkompajlati_procesh2=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 kodexec(str_ngh)File "<string>", line 1import os ,sys ;^SyntaxError: invalid syntax PS: How can I change when user write script with my program to he don''t needaspirate the lines of his source codee.g.import os,sysn=90if n==90:print "OK"else:print "No"Regards, Vedran__________________________________________________ ________________ Vedranveki ICQ#: 264412055 Current ICQ status: + More ways to contact me Get ICQ!__________________________________________________ ________________ 推荐答案 这几乎可以肯定是因为代码包含嵌入式运输 返回: This is almost certainly because the code contains embedded carriagereturns: bok kaj ima bok kaj ima Traceback(最近一次调用最后一次): 文件"< s tdin>",第1行,在< module> 文件"< string>",第1行 import os,sys; ^ 语法错误:语法无效 Traceback (most recent call last):File "<stdin>", line 1, in <module>File "<string>", line 1import os,sys;^SyntaxError: invalid syntax 我'恐怕我不明白这个问题。如果你在谈论 代码的缩进,如果你不想缩进,你将有 来使用大括号 - {和} - 来表示嵌套你的节目结构。 问候 史蒂夫 - 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 aboutthe indentation of the code, if you don''t want indentation you will haveto use braces - { and } - to indicate the nesting structure of your program. regardsSteve--Steve Holden +1 571 484 6266 +1 800 494 3119Holden Web LLC/Ltd http://www.holdenweb.comSkype: holdenweb http://del.icio.us/steve.holden--------------- Asciimercial ------------------Get on the web: Blog, lens and tag the InternetMany services currently offer free registration----------- Thank You for Reading ------------- 哦,我这样戏弄n00bs并不好。你知道Python没有 使用大括号,它使用BEGIN ... END块。 - 史蒂文。 Oh my, teasing the n00bs like that is not nice. You know Python doesn''tuses braces, it uses BEGIN ... END blocks.--Steven. 这几乎可以肯定是因为代码包含嵌入式运输 返回: This is almost certainly because the code contains embedded carriagereturns: bok kaj ima bok kaj ima 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 我怕我不明白这个问题。如果你在谈论 代码的缩进,如果你不想缩进,你将有 来使用大括号 - {和} - 来表示嵌套你的节目结构。 问候 史蒂夫 - 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 aboutthe indentation of the code, if you don''t want indentation you will haveto use braces - { and } - to indicate the nesting structure of your program.regards Steve--Steve Holden +1 571 484 6266 +1 800 494 3119Holden Web LLC/Ltd http://www.holdenweb.comSkype: holdenweb http://del.icio.us/steve.holden--------------- Asciimercial ------------------Get on the web: Blog, lens and tag the InternetMany services currently offer free registration----------- Thank You for Reading ------------- 你好, 感谢以前的所有事情,但我只想问代码 缩进,这与{和}有关n'n 就业,这是我的例子我如何解决这个代码 缩进: Hello, Thanks for everything previously, but just to I ask about codeindentation,this with { and } doesn''temployed, here is my example how can I solve this about codeindentation: {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 syntaxThanks!!!!!!! Regards,Vedran 这篇关于exec的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-02 11:00