【问题标题】:Python shell not printing list, only printing <type 'list'> [closed]Python shell 不打印列表,只打印 <type 'list'> [关闭]
【发布时间】:2014-05-08 17:37:38
【问题描述】:

我有一个非常简单的 Python 程序,但它没有在 shell 中打印出列表。

程序是:

list1 = [20]
print "list1 = ", list

def change(alist):
    alist.append(100)

change(list1)   
print "list1 = ", list

当我在 shell 中尝试时,我得到了

>>> import test
list1 =  <type 'list'>
list1 =  <type 'list'>

如何打印出列表中的实际值?

【问题讨论】:

  • 你打错了,朋友。尝试打印 list1 而不是 list。

标签: python list shell output


【解决方案1】:

您正在打印list 类型。要打印list1,请执行以下操作:

print "list1 = ", list1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 2021-02-15
    • 2015-03-16
    • 2015-01-04
    • 1970-01-01
    • 2020-06-13
    相关资源
    最近更新 更多