python学习笔记

元祖:sxs = (“cc”,"dcd")  不可更改  调用:sxs[0],sxs[1]

列表:sax = [ "sx", "sx"]  可更改  调用 :sax[0],sax[1]
更改: sax[count] = "sdcs" 
添加一个元素:sax.append("dscs")
添加多个元素:sax.extend([ "sc", "cds"])
temperatures = [12, 11,32,32]
temperatures.append(34)
temperatures.extend([21,232,432])
查看:temperatures

从列表中创建的片段是列表,丛原组中创建的片段还是元祖,字符串的片段还是字符串

python 核心类型: 元组,列表,字典,集合
三种特殊类型:None  True  False


关于 ‘_doc_' 的 ’AttributeError‘

代码如下:
# Filename:   doc.py
def printMax(x, y):
  '''Prints the maximum of two numbers.

  The two values must be integers.'''
  x = int(x)
  y = int(y)

  if x > y:
  print x, 'is maximum'
  else:
  print y, 'is maximum'

printMax(3, 5)
print printMax.__doc__

运行结果:
xiyousmalltiger@xiyousmalltiger-laptop:~$ python doc.py
5
Traceback (most recent call last):
  File "doc.py", line 14, in <module>
  print printMax._doc_
AttributeError: 'function' object has no attribute '_doc_'
请问是什么原因?是不是我系统里的python安装的不完整?我的系统为Ubuntu8.10
================
================

回复 1# smalltiger.lee 的帖子

是__doc__属性,而不是_doc_属性,注意是两个下划线。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值