-2
\$\begingroup\$

I'm trying to extract a file with python 3(for my game launcher), and this is the code I'm using:

import zipfile f = open('filenamehere.zip', 'rb') z = zipfile.ZipFile(f) for name in z.namelist(): outpath = "" z.extract(name, outpath) fh.close() 

I can't seem to figure out how to change outpath to get it to put it in a relative position. ._.

\$\endgroup\$
3
  • \$\begingroup\$ Programming questions belong to StackOverflow. \$\endgroup\$ Commented May 14, 2016 at 21:19
  • \$\begingroup\$ It is for my game launcher. Plus, I got banned from stackoverflow for asking bad questions. .-. \$\endgroup\$ Commented May 14, 2016 at 21:36
  • 1
    \$\begingroup\$ You're asking a general programming question, see help center. Just because you can't ask it on Stack Overflow doesn't mean you can ask it here (I say that kindly and respectfully). \$\endgroup\$ Commented May 14, 2016 at 22:31

1 Answer 1

1
\$\begingroup\$

Try this:

import os myPath = os.path.join(os.getcwd(),'filename.zip') f = open(myPath, 'rb') 

It gets the current working directory and joins the file name.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ Try not to answer off topic questions, I've made the same mistake before and it doesn't help anyone. \$\endgroup\$ Commented May 14, 2016 at 22:33
  • \$\begingroup\$ At least if it gets closed, someone will get their answer. Also, how would it not help the person who is asking the question? \$\endgroup\$ Commented May 14, 2016 at 22:36
  • 1
    \$\begingroup\$ It fills up GameDev with irrelevant questions and deteriorates the quality of this site. The person who asked this gets his answer and thinks he can get what he wants on SX by not following the community guidelines and has no reason to change his behavior until he gets banned from asking questions, which is what happened with his StackOverflow. In the long run it hurts the community and him. \$\endgroup\$ Commented May 14, 2016 at 22:39
  • \$\begingroup\$ If I had the ability, I would vote to close the question. \$\endgroup\$ Commented May 14, 2016 at 22:41
  • 1
    \$\begingroup\$ As it says at help center, and as you surely know, generic programming questions belong to SO. Game developers do not provide better answers to this specific problem, which is a basic Python file IO issue. It doesn't matter what the piece of code in the end is for. \$\endgroup\$ Commented May 15, 2016 at 5:46

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.