Python/CheatSheet: Difference between revisions
Appearance
< Python
No edit summary |
No edit summary |
||
| Line 46: | Line 46: | ||
= Functions = | |||
== datetime == | |||
<blockquote> | <blockquote> | ||
<pre> | <pre> | ||
today() | |||
now(timezoneinfo) | |||
utcnow() | |||
fromordinal(ordinal) | |||
combine(date,time) | |||
strptime(date,format) | |||
strftime() | |||
fromtimestamp(timestamp) | |||
utcfromtimestamp(timestamp) | |||
</pre> | </pre> | ||
</blockquote> | </blockquote> | ||
Revision as of 11:33, 18 September 2017
Variables
Tuples
Lists
Dictionaries
Flow Control
If Then Else
if x < 0:
print('Negative')
elif x == 0:
print('Zero')
else:
print('More')
For loops
for x in ['cat', 'dog', 'bird']:
print (w)
While loops
while test:
print (answer)
while True:
print (answer)
if answer == '2':
break
Functions
datetime
today() now(timezoneinfo) utcnow() fromordinal(ordinal) combine(date,time) strptime(date,format) strftime() fromtimestamp(timestamp) utcfromtimestamp(timestamp)