Welcome To Snipplr
Everyone's Recent Python Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
Always gives me perfect date.
Sample Output
Current Day is: 1
Current Month is: 2
Current Year is: 2020
Current Hour is: 17
Current Minute is: 3
Current Second is: 8
Current Microsecond is: 556483
2
14650
posted 4 years ago by johnwalsh1
Name this script whatever you want, and run it via Workbench Scripting shell
0
1188
posted 7 years ago by acosonic
Just try the following Python Sample SMS Code scripts and you will find that sending SMS to your contact via this programming script is fun!
1
1517
posted 7 years ago by Broadnet
Calculates the lcm of 2 or more numbers (based on a self-made algorithm)
0
990
posted 7 years ago by amirteymuri
This shows how to convert values from a dictionary and make them a list.
0
1203
posted 8 years ago by GabrielTheodoulos
arr[::-1] does a list slice to reverse the array
str(x) for x in arr[::-1] casts the ints in the array as strings
map(str, arr[::-1]) does the same thing by using map to cast the ints
" ".join() joins the resulting strings with a space
1
1173
posted 8 years ago by denisemauldin
The try ... except statement has an optional else clause, which, when present, must follow all except clauses. It is useful for code that must be executed if the try clause does not raise an exception. For example:
0
994
posted 8 years ago by ManishChandraReddy
Display the google chrome bookmarks to html and then save to database.
1
1732
posted 9 years ago by Gauravwagh11
check email address whether valid or not by checking list of MX servers and send email command - will work as long as the SMTP server of target domain not be protected / the VRVY not be disabled in MX server.
1
985
posted 9 years ago by brm
One day I got to wondering if it was possible to get a Python script to modify itself. After a few searches I found a solution that I present here. I did not write this code, but feel that it should be "paid forward" so others know that it is possibl...
1
1180
posted 9 years ago by BustACode
I am tired of having to go through text and adding quotation marks and commas to strings or just commas after numbers... f-that. Fixed.
0
1008
posted 9 years ago by joshuaherman
A simple Python censor script that takes 2 arguments. One is for the text you want to censor and the other is the list of words that should not be viewed.
0
966
posted 9 years ago by arielinfante
Overview
In an earlier post "OS.walk in Python", I described how to use os.walk and showed some examples on how to use it in scripts.
In this article, I will show how to use the os.walk() module function to walk a
directory tree, and the fnma...
1
1126
posted 9 years ago by tionazo
Get all links from a website
from: http://www.pythonforbeginners.com/code/regular-expression-re-findall
0
2183
posted 9 years ago by tionazo
A simple program to calculate the area and perimeter of a circle and to calculate the area and volume of a sphere.
Source is commented,
0
1053
posted 10 years ago by Tharix
Flatten a list of lists (or tuple of tuples, list of tuples, etc.) to any depth of nesting using no mutable objects.
1
1362
posted 10 years ago by alces
Author: jsinix([email protected])
This script is written to expedite the process of initial system configuration
(specifically Ubuntu). These initial things include basic setup, securing the
system(firewall), updating it etc. I have not test...
0
1080
posted 10 years ago by jsinix
To store you item into mysql database.
1. I say you have been have mysql database and the table what field is the same in item class that you wang to be stored
2. I just ensure you item insert into mysql, do not ensure the performance
3. To...
0
1696
posted 10 years ago by zwidnypublic
Utiliza os dados do site:
http://www.portaltransparencia.gov.br/downloads/servidores.asp
Escolha um mês e ano, baixe o .zip, descompacte e na pasta descompactada, execute.
0
916
posted 10 years ago by torresbernardo
Usage:
1. save the snippet as *fabfile.py*
2. and run:
**$ fab -H myhost1,myhost2...**
or set *env.roledefs['myrole'] = ['myhost1', 'myhost2', ...]* in *fabfile.py* and run this way:
**$ fab -R myrole**
0
1124
posted 10 years ago by alces
his simple patch solves the problem when building on windows with usernames with non-ascii letters.
0
1087
posted 10 years ago by composite
for Cron:
# run
$ crontab -e
# then add this
*/1 * * * * export DISPLAY=:0.0 && /home/username/path/to/script.py > /dev/null
# then save.
# This cron job will run every minute
0
1069
posted 10 years ago by pantuts
Tiny python closure for combining redis keys with "format".
Uses a closure so it does not remake the base key each use.
0
905
posted 10 years ago by dsonbill
Gets system, machine, OS and networking information and either writes it to a file or returns the data as a string.
1
1002
posted 10 years ago by JordanRowles
These logging functions will be improved and added into the SocketServer_Server.py to log information from programs on machines on the same network, but not directly connected to each other.
0
1049
posted 10 years ago by JordanRowles