Python-Ref > Basic usage > Types > Type conversions
 
 

<-^^->
Klíčová slova
Moduly
Knihovní funkce

Type conversions

Type conversions are often necessary to process data.
Expand/Shrink
Zdroj: (types3-1.py)
  1   i = 1
  2   x = 0.05
  3   s1 = "hi"
  4   s2 = "2"
  5   s3 = '1.3'
  6   
  7   print str( i) + s2
  8   print i + int( s2)
  9   print 3*float( s3)
 10   print 3*s3  # multiplying a string by interger means repetition
 11   print int( x)  # in this case the float is truncated
stdout:
12
3
3.9
1.31.31.3
0
Doba běhu: 21.2 ms