pythonдÎļþʱ³öÎÊÌâ
Òì³£´úÂëÈçÏ£º
write a file error: [Errno 2] No such file or directory: 'C:\x0cile.txt'
Traceback (most recent call last):
File "C:\Documents and Settings\USER\×ÀÃæ\¸´¼þ test.py", line 84, in <module>
test()
File "C:\Documents and Settings\USER\×ÀÃæ\¸´¼þ test.py", line 78, in test
writefile(s)
File "C:\Documents and Settings\USER\×ÀÃæ\¸´¼þ test.py", line 59, in writefile
f.write(str(string))
UnboundLocalError: local variable 'f' referenced before assignment
Python code:
¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£¡£
def writefile(string):
strfile="C:\file.txt"
try:
f = open(strfile,'a')
except IOError,e:
print "write a file error:",e
f.write(str(string))
f.close()
def test():
fname = 'C:\ZLLKDoc.cpp'
#raw_input('Enter filename: ')
try:
fobj = open(fname, 'r')
except IOError, e:
print "*** file open error:", e
strFile=fobj.read()
fobj.close()
s = eraser(strFile)
print s
ʵÔÚ²»ÖªµÀÄÄÀï´íÁË£¬Çë´óÏÀÃǰïæ¿´¿´£¬¸Ð¼¤²»¾¡
test£¨£© º¯ÊýÖеÚÒ»ÐмÓÈë global f
È»ºóÄãµÄÁ½¸öº¯ÊýµÄÂß¼
Ïà¹ØÎÊ´ð£º
ÎÒÿ´ÎÉÏ´«µÄÎļþ¶Áµ½µÄÊý¾Ý¶¼²»ÕýÈ·¡£2M µÄͼƬ¶ÁµÃ10¶àK ¡£¡£ÄÄλ´óÏÀ¿ÉÒÔ°ï°ïÎÒ°¡¡£
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......
ÇëÎʸßÊÖ£¬pythonÀïµÄpopenÀàËÆjavaÀïµÄÄĸöÀà»òÕß·½·¨ÄØ£¿£¿ÁíÍâjython¿ª·¢java¸ÃÈçºÎʹÓÃjythonÄØ£¿£¿
1.¿ÉÄܺÍjavaÀïµÄRuntime.getRuntime().exec£¨"ϵͳÃüÁî"£©; Æô¶¯½ø³Ì
2.eclipseÏÂÔØjython ²å¼ ......
²ËÊÖÇë½ÌÖîλÀÏÄñ£º
ÎÒÏ£Íû±à¼zipѹËõ°üÀïµÄÒ»¸öÎı¾Îļþ¡£Ôõô½â¾ö±È½ÏºÏÀí£¿
ÎÒµÄÏë·¨£ºÏȰÑZIP½âѹ£¬ÔÙ±à¼Îı¾£¬È»ºóÔÙѹËõ³ÉZIP²¢°Ñ½âѹ¹ýµÄÎļþɾ³ý¡£²»¹ý¸Ð¾õÓÐЩ·±Ëö£¬¿É²»¿ÉÒÔÖ±½Ó¶ÁZIPÈ»ºóÐÞ¸ÄÄØ£¿ ......
Python code:
class A:
def __init__(self):
self.B_Handle = B_Handle
self.VA = "A_init"
print "Class A init"
def __getattr__(self, name):
......