Python中常见类型的常用函数

Python中常见类型的常用函数

1 列表(list)类型的常用函数

list() -> new empty list
list(iterable) -> new list initialized from iterable's items

L.append(object) -> None -- append object to end
L.clear() -> None -- remove all items from L
L.copy() -> list -- a shallow copy of L
L.count(value) -> integer -- return number of occurrences of value
L.extend(iterable) -> None -- extend list by appending elements from the iterable
L.index(value[, start[, stop]]) -> integer --return first index of value.
L.insert(index, object) -- insert object before index
L.pop([index]) -> item -- remove and return item at index (default last).
L.remove(value) -> None -- remove first occurence of value.
L.reverse() -- reverse *IN PLACE*
L.sort(key = None, reverse = False) -> None -- stable sort *IN PLACE*

2 字典(dict)类型的常用函数

3 字符串(str)类型的常用函数

str(object = '') -> string
S.join(iterable) -> string
S.strip([chars]) -> string or unicode -- Return a copy of the string S with leading and trailing whitespace removed.

4 文件(file)类型的常用函数

file(name[, mode[, buffering]]) -> file object
F.close() -> None or (perhaps) an integer. Close the file.
F.read([size]) -> read at most size bytes, returned as a string.
F.readline([size]) -> next line from the files, as a string.
F.readlines([size]) -> list of strings, each a line from the file.
F.write(str) -> None. Write string str to file.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值