python convert a string to a integer for multiplication

This question already has an answer here:

  • How do I parse a string to a float or int in Python? 22 answers

  • Wrap your input in either int or float

    number=int(input("Enter a number to multiply by 9 "))
    

    or

    number=float(input("Enter a number to multiply by 9 "))
    

    This is done because input accepts strings and you have to convert these to numerals.

    链接地址: http://www.djcxy.com/p/48426.html

    上一篇: 如何在Python 3.x中强制整数输入?

    下一篇: python将一个字符串转换为一个整数用于乘法