本文整理匯總了Python中src.tools.path.Path.get_img_size_by_filename_kb方法的典型用法代碼示例。如果您正苦於以下問題:Python Path.get_img_size_by_filename_kb方法的具體用法?Python Path.get_img_size_by_filename_kb怎麽用?Python Path.get_img_size_by_filename_kb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類src.tools.path.Path
的用法示例。
在下文中一共展示了Path.get_img_size_by_filename_kb方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: download_img
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import get_img_size_by_filename_kb [as 別名]
def download_img(self):
from src.container.image_container import ImageContainer
img_container = ImageContainer()
img_src_dict = Match.match_img_with_src_dict(self.content)
self.img_filename_list = []
for img in img_src_dict:
src = img_src_dict[img]
filename = img_container.add(src)
self.img_filename_list.append(filename)
self.content = self.content.replace(img, Match.create_img_element_with_file_name(filename))
# 下載文章封麵圖像
filename = img_container.add(self.image_url)
self.img_filename_list.append(filename)
self.image_url = Match.create_local_img_src(filename)
# 下載用戶頭像
filename = img_container.add(self.author_avatar_url)
self.img_filename_list.append(filename)
self.author_avatar_url = Match.create_local_img_src(filename)
img_container.start_download()
# 下載完成後,更新圖片大小
for filename in self.img_filename_list:
self.total_img_size_kb += Path.get_img_size_by_filename_kb(filename)
return
示例2: download_img_in_question_content
# 需要導入模塊: from src.tools.path import Path [as 別名]
# 或者: from src.tools.path.Path import get_img_size_by_filename_kb [as 別名]
def download_img_in_question_content(self):
# 下載問題詳情中的圖片,同時更新
from src.container.image_container import ImageContainer
img_container = ImageContainer()
img_src_dict = Match.match_img_with_src_dict(self.question_info.detail)
self.question_content_img_filename_list = []
for img in img_src_dict:
src = img_src_dict[img]
filename = img_container.add(src)
self.question_content_img_filename_list.append(filename)
self.question_info.detail = self.question_info.detail.replace(img, Match.create_img_element_with_file_name(filename))
img_container.start_download()
# 下載完成後,更新圖片大小
for filename in self.question_content_img_filename_list:
self.question_content_img_size += Path.get_img_size_by_filename_kb(filename)
return