This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.path.join('/home', 'User/Desktop', 'file.txt') | |
# '/home/User/Desktop/file.txt' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
os.path.isfile("bob.txt") # Does bob.txt exist? Is it a file, or a directory? | |
os.path.isdir("bob") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from urllib.parse import urlencode | |
base_url = 'https://cloud-api.yandex.net/v1/disk/public/resources/download?' | |
public_key = 'https://yadi.sk/d/UJ8VMK2Y6bJH7A' # Сюда вписываете вашу ссылку | |
# Получаем загрузочную ссылку | |
final_url = base_url + urlencode(dict(public_key=public_key)) | |
response = requests.get(final_url) | |
download_url = response.json()['href'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, glob, getopt, os | |
import cv2 | |
VIDEO_FILE_EXT = ['*.mp4', '*.mov', '*.avi'] | |
def findAllVideoFiles(directory, recursiveSearch): | |
videoFiles = [] | |
for ext in VIDEO_FILE_EXT: | |
pattern = os.path.join( | |
directory, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('out.txt', 'w') as f: | |
print('Filename:', filename, file=f) # Python 3.x | |
print >> f, 'Filename:', filename # Python 2.x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
except (IDontLikeYouException, YouAreBeingMeanException) as e: | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import moviepy.editor as mp | |
def extract_audio(video, audio): | |
my_clip = mp.VideoFileClip(video) | |
my_clip.audio.write_audiofile(audio) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum, auto | |
class Color(Enum): | |
RED = auto() | |
BLUE = auto() | |
GREEN = auto() | |
list(Color) # [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_random_module(modules): | |
module_name = random.choice(modules) | |
__import__(module_name) |