Discuss Scratch
- Discussion Forums
- » Things I'm Making and Creating
- » Help on a Python project
- navysmeagol_175
-
Scratcher
100+ posts
Help on a Python project
I am trying to make a project that reads sb2 files.
Heres the __code__
Heres the __code__
import json
import os
file_loc=input(“list the location of a scratch file”)
#os.isfile(file_loc)
if 1==1:
try:
s_file= open(file_loc+“/project.json”, ‘r’)
except:
print (“ERROR! FILE %s \'S DATA IS INACCESSABLE” %file_loc)
fail=True
if not fail:
s_txt= s_file.read()
exp_loc =input('export to where')
s_file.close()
exp_file=open (exp_loc,'w')
exp_file.write(s_txt)
exp_file.close()
else:
print (''' File does not exist''')
- __init__
-
Scratcher
1000+ posts
Help on a Python project
Is this Python 2 or 3?
Also I don't see the point of your “if 1==1” clause. Of course 1==1.
And the “else” will never happen.
Also you need a library to read zip files. Try the zipfile library.
Also I don't see the point of your “if 1==1” clause. Of course 1==1.
And the “else” will never happen.
Also you need a library to read zip files. Try the zipfile library.
- navysmeagol_175
-
Scratcher
100+ posts
Help on a Python project
Is this Python 2 or 3?python 3.
Also I don't see the point of your “if 1==1” clause. Of course 1==1.
And the “else” will never happen.
Also you need a library to read zip files. Try the zipfile library.
the if 1==1 was there beacause i was trying to use os.isfile() and i got an error and was to lazy to rewrite all the code.
- sicilia
-
Scratcher
81 posts
Help on a Python project
I just made a Python forum for anything else. https://scratch.mit.edu/discuss/topic/136252/?page=1#post-1234396
Scratch On!
Last edited by sicilia (July 23, 2015 13:54:14)
- Discussion Forums
- » Things I'm Making and Creating
-
» Help on a Python project