Created
August 27, 2016 05:34
-
-
Save shinshin86/bc25d36801bbfe6d31c615a0d594e8bf to your computer and use it in GitHub Desktop.
This file contains 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
# Please use "copy and paste" at Your Python environment. | |
# I have been tested with Python3. | |
# Hello World | |
python -c "print('Hello World')" | |
# Create Files(Example: Create a 10 pcs "text" file) | |
python -c "import random;[open(str(random.randint(1, 100000)) +'.txt', 'w').close() for i in list(range(10))]" | |
# Rename a all file name in the directory("jpg"file) | |
python -c "import sys, os, re;[os.rename(file, 'image%04d.jpg' % num) for num, file in enumerate(os.listdir(os.getcwd())) if re.compile('jpg$w').search(file)]" | |
# Start local server(Port 8080) | |
python -m http.server 8080 | |
# Resize to half size a Image file(JPEG) | |
# Please 'Your Target Image file' write to 'FileName is here' | |
python -c "globals()['file'] = 'FileName is here';import sys,os,re;from PIL import Image;globals()['target_image'] = Image.open(file); x_size = int(target_image.size[0] / 2); y_size = int(target_image.size[1] / 2);globals()['target_image2'] = target_image.resize((x_size,y_size));globals()['resize_name'] = 'resize_' + file;target_image2.save(resize_name, 'JPEG')" | |
# JSON display | |
# Please 'JsonFile is here' write to 'JsonFile is here' | |
python -c "json_file = 'JsonFile is here';import json;f = open(json_file, 'r');jsonData = json.load(f);print(json.dumps(jsonData, sort_keys = True, indent = 4));f.close()" | |
# Random password generate | |
python -c "from random import choice; print ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789') for i in range(16)])" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment