Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以给一个怎么添加音乐播放器的教程吗? #5

Open
laibinzhi opened this issue Aug 8, 2018 · 2 comments
Open

可以给一个怎么添加音乐播放器的教程吗? #5

laibinzhi opened this issue Aug 8, 2018 · 2 comments

Comments

@laibinzhi
Copy link

如题

@lawlite19
Copy link
Owner

不好意思刚看到,就按照里面的教程来 : https://aplayer.js.org/#/home

@lawlite19
Copy link
Owner

`def handle_photo():
'''根据图片的文件名处理成需要的json格式的数据

-----------
最后将data.json文件存到博客的source/photos文件夹下
'''
src_dir, des_dir = "photos/", "min_photos/"
file_list = list_img_file(src_dir)
print(file_list)
list_info = []
for i in range(len(file_list)):
    filename = file_list[i]
    date_str, info = filename.split("_")
    info, _ = info.split(".")
    date = datetime.strptime(date_str, "%Y-%m-%d")
    year_month = date_str[0:7]
    if i == 0:  # 处理第一个文件
        new_dict = {"date": year_month, "arr":{'year': date.year,
                                               'month': date.month,
                                               'link': [filename],
                                               'text': [info],
                                               'type': ['image']
                                               }
                    }
        list_info.append(new_dict)
    elif year_month != list_info[-1]['date']:  # 不是最后的一个日期,就新建一个dict
        new_dict = {"date": year_month, "arr":{'year': date.year,
                                               'month': date.month,
                                               'link': [filename],
                                               'text': [info],
                                               'type': ['image']
                                               }
                    }
        list_info.append(new_dict)
    else:  # 同一个日期
        list_info[-1]['arr']['link'].append(filename)
        list_info[-1]['arr']['text'].append(info)
        list_info[-1]['arr']['type'].append('image')
list_info.reverse()  # 翻转
tmp = bubbleYear(list_info)
bubble(tmp)
final_dict = {"list": list_info}
with open("../deweyliu.github.io/source/photos/data.json","w") as fp:
    json.dump(final_dict, fp)`

Traceback (most recent call last):

File "tool.py", line 196, in
handle_photo() # 将文件处理成json格式,存到博客仓库中
File "tool.py", line 101, in handle_photo
date_str, info = filename.split("_")
ValueError: not enough values to unpack (expected 2, got 1)
很奇怪 开始代码还可以用的 后来handle_photo()这个方法就开始报错 不知道为什么 对python语法还不是太熟悉

是图片命名没有按要求吧,我没有做处理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants