User Tools

Site Tools


python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
python [2021/01/22 18:04] – created rogerpython [2023/01/01 18:43] (current) – external edit 127.0.0.1
Line 73: Line 73:
  
 ==== Convert strings to datetime ==== ==== Convert strings to datetime ====
 +
 +More info https://stackabuse.com/converting-strings-to-datetime-in-python/
  
 <code python> <code python>
Line 103: Line 105:
 print('yay!') if today == 'friday' else print('boo') print('yay!') if today == 'friday' else print('boo')
 >>> yay!  >>> yay! 
 +</code>
 +
 +==== Unpack extras on a tuple or list ====
 +
 +<code python>
 +t = (0, 1, 2, 3, 4)
 +
 +a, b, *c = t
 +
 +print(a)
 +print(b)
 +print(c)
 +# 0
 +# 1
 +# [2, 3, 4]
 +
 +print(type(c))
 +# <class 'list'>
 +
 +a, *b, c = t
 +
 +print(a)
 +print(b)
 +print(c)
 +# 0
 +# [1, 2, 3]
 +# 4
 +
 +*a, b, c = t
 +
 +print(a)
 +print(b)
 +print(c)
 +# [0, 1, 2]
 +# 3
 +# 4
 +
 </code> </code>
  
  
python.1611349459.txt.gz · Last modified: 2023/01/01 18:43 (external edit)