十分钟学会Python, 简单入门教程(6)

http://www.smzswang.com时间:2016-10-23 14:21来源:未知

  >>> sample = [1, ["another", "list"], ("a", "tuple")]

  >>> mylist = ["List item 1", 2, 3.14]

  >>> mylist[0] = "List item 1 again" # We're changing the item.

  >>> mylist[-1] = 3.21 # Here, we refer to the last item.

  >>> mydict = {"Key 1": "Value 1", 2: 3, "pi": 3.14}

  >>> mydict["pi"] = 3.15 # This is how you change dictionary values.

  >>> mytuple = (1, 2, 3)

  >>> myfunction = len

  >>> print myfunction(mylist)

  3

【免责声明】本文仅代表作者个人观点,与中国数码招商网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。您若对该稿件内容有任何疑问或质疑,请联系本网将迅速给您回应并做处理。

相关新闻