function3.py 720 B

12345678910111213141516171819202122232425262728293031
  1. """
  2. Python的内置函数
  3. - 数学相关: abs / divmod / pow / round / min / max / sum
  4. - 序列相关: len / range / next / filter / map / sorted / slice / reversed
  5. - 类型转换: chr / ord / str / bool / int / float / complex / bin / oct / hex
  6. - 数据结构: dict / list / set / tuple
  7. - 其他函数: all / any / id / input / open / print / type
  8. Version: 0.1
  9. Author: 骆昊
  10. Date: 2018-03-05
  11. """
  12. def myfilter(mystr):
  13. return len(mystr) == 6
  14. # help()
  15. print(chr(0x9a86))
  16. print(hex(ord('骆')))
  17. print(abs(-1.2345))
  18. print(round(-1.2345))
  19. print(pow(1.2345, 5))
  20. fruits = ['orange', 'peach', 'durian', 'watermelon']
  21. print(fruits[slice(1, 3)])
  22. fruits2 = list(filter(myfilter, fruits))
  23. print(fruits)
  24. print(fruits2)