好的,謝謝大家的幫助。我有第二個問題。我在觀看視頻流時需要聊天,並且可能會使用irc。服務器爲irc.twitch.tv
,頻道與livestreamer名稱相同。當我嘗試這個代碼時,它給了我錯誤。Python子進程和raw_input
# -*- coding: latin-1 -*-
import subprocess
print(35*"+")
name = raw_input("Livestreamer name\n")
hostVideo = subprocess.Popen(['livestreamer', 'twitch.tv/'+name, 'best'], stdout = subprocess.PIPE).communicate()[0]
hostIrssi = subprocess.Popen(['irssi --connect=irc.twitch.tv --password=oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --nick=nickname'], stdout = subprocess.PIPE).communicate()[0]
print hostVideo
print hostIrssi
這是錯誤我得到了什麼
Traceback (most recent call last):
File "Livestreamer.py", line 7, in <module>
hostIrssi = subprocess.Popen(['irssi --connect=irc.twitch.tv --password=oauth:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --nick=nickname'], stdout = subprocess.PIPE).communicate()[0]
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
而且如果可能的話,告訴我如何讓它加入自動右聲道。
我大後
我喜歡看抽搐串流和我想要做的腳本,詢問livestreamer名,然後發送命令到終端。 Livestreamer命令就像
livestreamer twitch.tv/user best
所以腳本必須用戶之後添加livestreamer命令後,「twitch.tv/」和「最佳」。 我的代碼如下所示:
# -*- coding: latin-1 -*-
import subprocess
user = raw_input("Livestreamers name:\n")
livestreamer = "livestreamer twitch.tv/"
host = subprocess.Popen(['livestreamer', 'twitch.tv/', user, 'best'], stdout = subprocess.PIPE).communicate()[0]
print host
輸出是
livestreamer: error: unrecognized arguments: best
如果有人知道什麼是錯的,我好高興。也對不起我的壞英語。 :)
無關:您可以替換'output = subprocess.Popen(..)。communicate(..)[0] ''output = subprocess.check_output(['livestreamer','twitch.tv /'+ sanitize(user),'best'])'或者你不需要輸出:'subprocess.check_call([.. ],標準輸出= DEVNULL)'。儘管看起來'livestreamer'沒有產生太多的輸出,因此在'communicate()'/'check_output()'函數中存儲內存中整個子進程的輸出沒有問題。 – jfs
你應該把*「OSError:[Errno 2]沒有這樣的文件或目錄」*問題到一個單獨的問題。儘管答案與*「livestreamer:error:無法識別的參數:最佳」錯誤相同,即:一個命令行參數 - >一個列表項。 – jfs