YaoRaoLov 2008-12-31 07:58 采纳率: 50%
浏览 769

如何确定 Python 变量的类型?

How do I see the type of a variable whether it is unsigned 32 bit, signed 16 bit, etc.?

How do I view it?

转载于:https://stackoverflow.com/questions/402504/how-to-determine-a-python-variables-type

  • 写回答

15条回答 默认 最新

  • local-host 2008-12-31 08:02
    关注
    print type(variable_name)
    

    I also highly recommend the IPython interactive interpreter when dealing with questions like this. It lets you type variable_name? and will return a whole list of information about the object including the type and the doc string for the type.

    e.g.

    In [9]: var = 123
    
    In [10]: var?
    Type:       int
    Base Class: <type 'int'>
    String Form:    123
    Namespace:  Interactive
    Docstring:
        int(x[, base]) -> integer
    

    Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. If the argument is outside the integer range a long object will be returned instead.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable