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
11014
posted 3 years ago by johnwalsh1
Name this script whatever you want, and run it via Workbench Scripting shell
0
830
posted 5 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
1077
posted 6 years ago by Broadnet
Calculates the lcm of 2 or more numbers (based on a self-made algorithm)
0
636
posted 6 years ago by amirteymuri
This shows how to convert values from a dictionary and make them a list.
0
859
posted 7 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
791
posted 7 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
677
posted 7 years ago by ManishChandraReddy
Display the google chrome bookmarks to html and then save to database.
1
1315
posted 7 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
664
posted 8 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
780
posted 8 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
655
posted 8 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
628
posted 8 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
758
posted 8 years ago by tionazo
Get all links from a website
from: http://www.pythonforbeginners.com/code/regular-expression-re-findall
0
1211
posted 8 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
665
posted 8 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
919
posted 8 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
711
posted 8 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
1314
posted 8 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
609
posted 8 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
732
posted 9 years ago by alces
his simple patch solves the problem when building on windows with usernames with non-ascii letters.
0
733
posted 9 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
712
posted 9 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
586
posted 9 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
637
posted 9 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
630
posted 9 years ago by JordanRowles