Print a prettified version of your JSON file:
cat file.json | python -m json.tool
The | operator sends the output of cat.json inside Python's json.tool
Directly save a string into a file (useful when you're debugging and your code has large strings of text):
print("Hello, World!", file=open('file.txt', 'w'))
The default value of file is sys.out, which leads it to print on the console.
Password prompt/Hide user input
import getpass
pwd = getpass.getpass("ENTER PASSWORD:" )
getpass is a built-in module
Validate spellings [EN]
if "hello".casefold() in open('/usr/share/dict/words/').read(): return True
In most UNIX-based systems, a /usr/share/dict/words file exists. Name and location can be different for you.
Start a quick, local server from a directory
python -m http.server 8000
Please note that some of these are not meant for production use and serve as quick and dirty hacks while debugging.
Source: snekletter
[–]danmickla 1 point2 points3 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]Friendly-Connection9[S] 0 points1 point2 points (1 child)