我有一个朋友做的python代码,因为我对python知之甚少。。
我想把它转换成一个图形用户界面,因为我们将把代码作为一个程序分发给初学者。在
不管怎样,代码是这样的:import time, os, sys
try:
if len(sys.argv) < 2:
fn = raw_input("Enter the name of the file you want to edit: ")
else: fn = sys.argv[1]
f = open(fn)
b = f.read()
for i in b[:300]:
print hex(ord(i))[2:],
f.close()
line = str(0x15c)+'-'+str(0x15f)
if len(sys.argv)<3:
hexcode = raw_input("3 bytes color hex number: ")
else: hexcode = sys.argv[2]
if not hexcode.startswith('0x'):
hexcode = '0x'+hexcode
hexstr = '0x'
start = int(line.split('-')[0])
end = int(line.split('-')[1])
for i in b[start:end]:
hexstr+=hex(ord(i))[2:]
ascii = ''
for i in range(2,len(hexcode),2):
char = chr(int(hexcode[i:i+2],16))
ascii+=char
b = b[:start]+ascii+b[end:]
for i in b[:300]:
print hex(ord(i))[2:],
except Exception, x:
print x
time.sleep(3)
finally:
f = open(fn,'wb')
f.write(b)
f.close()
现在我在一个教程上找到了这个,但不知道如何使用它:
#简单的GU0I
^{pr2}$
有什么帮助吗?
谢谢!在
还有一件事,在这段代码中,在我输入名称或replacor hex之后,它会显示一个hex列表,我怎么能使它不显示呢?在
谢谢!在