前提・実現したいこと
python3でsubprocessを使ってcurlで目的のファイルのダウンロードを行いたいです。
しかし次のようなエラーで実行できなくなっています。
ソースコード
python3
1import pandas as pd 2import subprocess 3df = pd.read_csv('file.csv') 4dg = df['aaa'].astype(str) #aaaは[1,2,3...]といったリスト 5 6for i in dg: 7 subprocess.call('curl', '-O', 'http://www.xxxxx.jp/~usr/dir1/' + i + '.txt /Users/username/') 8
エラーメッセージ
python3
1--------------------------------------------------------------------------- 2TypeError Traceback (most recent call last) 3<ipython-input-13-70d2202f8f0f> in <module>() 4 1 for i in dg: 5----> 2 subprocess.call('curl', '-O', 'http://www.xxxxx.jp/~usr/dir1/' + i + '.txt /Users/username/') 6 7~/anaconda3/lib/python3.6/subprocess.py in call(timeout, *popenargs, **kwargs) 8 265 retcode = call(["ls", "-l"]) 9 266 """ 10--> 267 with Popen(*popenargs, **kwargs) as p: 11 268 try: 12 269 return p.wait(timeout=timeout) 13 14~/anaconda3/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors) 15 607 bufsize = -1 # Restore default 16 608 if not isinstance(bufsize, int): 17--> 609 raise TypeError("bufsize must be an integer") 18 610 19 611 if _mswindows: 20 21TypeError: bufsize must be an integer 22
試したこと
''で役割が分かれて認識されていることがわかったので
('curl', '-o','http:...[i].txt /Users/username/')
と変更してくっつけて見たのですがダメでした。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。