How to convert strings into integers in Python?

后端 未结 15 2242
自闭症患者
自闭症患者 2020-11-22 01:33

I have a tuple of tuples from a MySQL query like this:

T1 = ((\'13\', \'17\', \'18\', \'21\', \'32\'),
      (\'07\', \'11\', \'13\', \'14\', \'28\'),
               


        
15条回答
  •  感动是毒
    2020-11-22 01:34

    In Python 3.5.1 things like these work:

    c = input('Enter number:')
    print (int(float(c)))
    print (round(float(c)))
    

    and

    Enter number:  4.7
    4
    5
    

    George.

提交回复
热议问题