Вот мой код.
import os, sys
if len(sys.argv) != 2:
sys.exit(1)
h = os.popen("wget -r %s") % sys.argv[1]
fil = open("links.txt","w")
dir = os.listdir("%s") % sys.argv[1]
for file in dir:
print file.replace("@","?")
fil.write("%s/"+file.replace("@","?")) % sys.argv[1]
fil.write("\n")
h.close()
запускает его, как этот python project.py http://google.com
дает мне код ошибки.
1.py:5 RuntimeWarning: tp_compare didnt return -1 or -2 for exception
h = os.popen("wget -r %s") % sys.argv[1]
Traceback (most recent call last):
File "1.py" line 5, in <module>
h = os.popen("wget -r %s") % sys.argv[1]
TypeError: unsupported operand type<s> for %: 'file' and 'str'
Что я не так делаю. (Все еще изучаю Python) Любое решение / совет?
Я не объясняю код, я думаю, вы понимаете, что я пытаюсь сделать