第二个循环中的选项字符串冲突
conflicting options string(s) on second loop
#main loop
while 1==1:
#If they click Yes on the dialog box begin recording, otherwise ask again
easygui.msgbox('This is what the last person suggested! Press ok to record.: ' + output_string, 'Title', ok_button= "OK")
N+=1
counterFile = open('counterFile','w')
counterFile.write(str(N));
counterFile.close()
camera.start_recording('video' + str(N) + '.h264')
audioRecord()
camera.stop_recording()
output_string_old = output_string;
output_string = TextEnter()
filename = ConvertMerge()
argparser.add_argument("--file")
argparser.add_argument("--title")
argparser.add_argument("--description")
argparser.add_argument("--category")
argparser.add_argument("--keywords")
argparser.add_argument("--privacyStatus")
args = argparser.parse_args(["--file", filename, "--title", str(N),"--description", output_string_old, "--category", "22", "--keywords", " ", "--privacyStatus", "public"])
initialize_upload(get_authenticated_service(args), args)
我制作了这段代码,用于记录镜头,然后使用 youtube api 上传到 youtube,但目前 returns 在第二个循环中出现此错误。
ArgumentError: argument --file: conflicting options string(s): --file
filename ='mergedVideo'+ str(N) + '.mkv'
并且每增加一次程序就是运行.
为什么在第二次循环时会出现这个错误?
您多次调用 parser.add_argument("--file"),而每个参数只能调用一次。只需在进入循环之前将所有 add_argument 调用移至右侧即可。
运行 此代码可能有助于理解问题所在:
import argparse
parser = argparse.ArgumentParser(description='test')
for i in range(2):
print i
parser.add_argument("--file")
parser.add_argument("stuff")
您会注意到第二次循环出现错误,因为您已经添加了一个名为“--file”的参数。
#main loop
while 1==1:
#If they click Yes on the dialog box begin recording, otherwise ask again
easygui.msgbox('This is what the last person suggested! Press ok to record.: ' + output_string, 'Title', ok_button= "OK")
N+=1
counterFile = open('counterFile','w')
counterFile.write(str(N));
counterFile.close()
camera.start_recording('video' + str(N) + '.h264')
audioRecord()
camera.stop_recording()
output_string_old = output_string;
output_string = TextEnter()
filename = ConvertMerge()
argparser.add_argument("--file")
argparser.add_argument("--title")
argparser.add_argument("--description")
argparser.add_argument("--category")
argparser.add_argument("--keywords")
argparser.add_argument("--privacyStatus")
args = argparser.parse_args(["--file", filename, "--title", str(N),"--description", output_string_old, "--category", "22", "--keywords", " ", "--privacyStatus", "public"])
initialize_upload(get_authenticated_service(args), args)
我制作了这段代码,用于记录镜头,然后使用 youtube api 上传到 youtube,但目前 returns 在第二个循环中出现此错误。
ArgumentError: argument --file: conflicting options string(s): --file
filename ='mergedVideo'+ str(N) + '.mkv'
并且每增加一次程序就是运行.
为什么在第二次循环时会出现这个错误?
您多次调用 parser.add_argument("--file"),而每个参数只能调用一次。只需在进入循环之前将所有 add_argument 调用移至右侧即可。
运行 此代码可能有助于理解问题所在:
import argparse
parser = argparse.ArgumentParser(description='test')
for i in range(2):
print i
parser.add_argument("--file")
parser.add_argument("stuff")
您会注意到第二次循环出现错误,因为您已经添加了一个名为“--file”的参数。