Tengo un código de Python y quiero ejecutarlo en Visual Studio. Nunca he tratado de hacer ejecutar un código de Python, a ver si sale.
He instalado los componentes necesario.
Código de Python:
Código
import os, sys, tkFileDialog,Tkinter root = Tkinter.Tk() root.withdraw() formats = [ ('Roms Super Nintendo SMC','.smc'),('Roms Super Nintendo SFC','.sfc'),('Fichier Bin','.bin'),('Roms Super Nintendo','.smc .sfc .bin') ] input = tkFileDialog.askopenfile(parent=root,mode='rb',filetypes=formats,title='Elija el archivo para swapper') if not input: print "¡Imposible de abrir el archivo!" sys.exit() output = tkFileDialog.asksaveasfile(parent=root,mode='wb',filetypes=formats,title='Elija el archivo de salida') if not output: print "¡No se puede crear el archivo de salida!" sys.exit() # Lectura del archivo de entrada a un array de bytes data = bytearray(input.read()) # Calculando el tamaño de la habitación en 2 exponentes expsize = 0 bytesize = len(data) while bytesize > 1: expsize += 1 bytesize = bytesize // 2 # Unidad de un tamaño adecuado matriz de bytes vacíos buffer = bytearray() for i in range(2**expsize): buffer.append(0) # let's do the swap count = 0 for i in range(len(data)): addr = (i & 0x7fff) + ((i & 0x008000) << (expsize - 16)) + ((i & 0x010000) >> 1) + ((i & 0x020000) >> 1) + ((i & 0x040000) >> 1) + ((i & 0x080000) >> 1) + ((i & 0x100000) >> 1) + ((i & 0x200000) >> 1) if addr != i: count += 1 buffer[addr] = data[i] print "Swapped %s (%s) addresses" % (count, hex(count)) # Escribir archivo de salida output.write(buffer) # Cerrar carpetas de archivos input.close() output.close()
Creo el proyecto de Python pero no tengo idea donde hay que darle exactamente con todo lo que tiene.
¿Alguna idea?
Saludos.





Autor



En línea


