Examples of octal, hexidecimal and binary numeric literals:
Code:
>>> 050
40
>>> 080
Traceback ( File "<interactive input>", line 1
080
^
SyntaxError: invalid token
>>>
>>> 050
40
>>> 080
Traceback ( File "<interactive input>", line 1
080
^
SyntaxError: invalid token
>>>
import re
pattern = re.compile(r"^\D+?_\D+?_(.+?)_")
def sort_on_TS(a, b):
return cmp(pattern.match(a).group(1), pattern.match(b).group(1))
for item in sorted(file_list, sort_on_TS):
print item
def sort_on_TS(a,b):
return cmp(a.split("_")[2], b.split("_
window.grab_release() window.withdraw() # do stuff here # restore the window window.deiconify() window.grab_set()
import random
print "Welcome to guess my number game!!!"
print "Please enter the number between 1 and 100"
number = random.randint(1, 100)
print number
max_guess = 5
tries = 0
while True:
guess = int(raw_input("Take a guess:
outFile.write("\n".join(log))
inputFile.close()
outFile.close()
#!/usr/bin/python # -*- coding: utf-8 -*- # http://zetcode.com/gui/tkinter/layout/ # http://docs.activestate.com/komodo/3.5/komodo-doc-guibuilder.html
outFile.write("\n".join(log))
data = """Jan 1 02:32:40 hello welcome to python world Jan 1 02:32:40 hello welcome to python world Mar 31 23:31:55 learn python Mar 31 23:31:55 learn python be smart Mar 31 23:31:56 python is good scripting language Jan 1 00:00:01 hello welcome to python world Jan 1 00:00:02 hello welcome to python world Mar 31 23:31:55 learn
>>> import re
>>> re.compile("[(](\d+, \d+)[)]")
<_sre.SRE_Pattern object at 0x0000000005C3EA80>
>>> pattern = re.compile("[(](\d+,
>>> my_string = '(1, 2) (3, 4)'
>>> eval(my_string.replace(") (", "),("))
((1, 2), (3, 4))
>>> a,b = eval(my_string.replace(") (", "),("))
>>> a
(1, 2)
>>> b
(3, 4)
>>>
>>> datetime.datetime.strptime("Jun 6 17:58:13", "%b %d %H:%M:%S")
datetime.datetime(1900, 6, 6, 17, 58, 13)
>>>
import re data = """Jun 6 17:58:13 other strings Jun 6 17:58:13 other strings Jun 6 17:58:14 other strings Jun 6 17:58:14 other strings Jun 6 17:58:15 other strings Jun 6 17:58:15 other strings Jun 6 17:58:15 other
import Tkinter
top = Tkinter.Tk()
def FstartCallBack():
top.grab_release()
top.withdraw()
# run your script here
B.pack_forget()
L = Tkinter.Label(top, text="Activated")
L.pack()
top.title("Action Complete")
top.minsize(width=250, height=20)
top.wm_deiconify()
>>> results = [["Ben", 15, 18,25, 6, 9], ["George", 25, 35, 85, 12, 9], ["Evie", 2, 54, 84, 62,18]] >>> for i, item in enumerate(results): ... results[i] = [item[0], max(item[1:])] ... >>> sorted(results) [['Ben', 25], ['Evie', 84], ['George', 85]] >>>
Leave a comment: