执行此代码时:
uploaded_file_info = ol.upload_file(c:\video\file.mp4)
print(uploaded_file_info)
效果很好
但是当我尝试从CSV文件循环播放时 它给出以下错误:
代码:
with open('ListTest.1.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
next(csv_reader)
for line in csv_reader:
print(line)
name = (line[0])
VidPath = (line[4])
print(name)
print(VidPath)
uploaded_file_info = ol.upload_file(VidPath)
print(uploaded_file_info)
跟踪:
Traceback (most recent call last):
File "PrintingTest.py", line 19, in <module>
uploaded_file_info = ol.upload_file(VidPath)
File "C:\Users\resta\Anaconda3\lib\site-packages\openload\openload.py", line 258, in upload_file
files={'upload_file': open(file_path, 'rb')}).json()
OSError: [Errno 22] Invalid argument: ' c:\video\file.mp4'
我在做什么错了?
答案 0 :(得分:2)
错误消息中的字符串开头似乎有一个空格。查看.strip()是否通过更改来修复它:
uploaded_file_info = ol.upload_file(VidPath)
到
uploaded_file_info = ol.upload_file(VidPath.strip())
您可能想以其他方式修复它,但这会立即告诉您是否是空格导致错误。
答案 1 :(得分:1)
请注意路径前面的空间。 ' c:\video\file.mp4'
。您的csvreader在','
(逗号)而不是', '
(逗号空间)上分割。将正确的定界符传递给reader
函数,或在第[4]行上使用字符串函数strip