list_data = [1,1.1,"hello",1+2j,b'123',None,True,(1,2,3),[1,2,3]] print(list_data) print(type(list_data)) D:pythonpython.exe D:/python/python_code/var_cod.py [1, 1.1, 'hello', (1+2j), b'123', None, True, (1, 2, 3), [1, 2, 3]]3.目前学到的序列有哪些?Process finished with exit code 0
将除tuple之外的序列转换为tuple
将除list之外的序列转换为list (1)字符串 字节 tuple list (2) 将除tuple之外的序列转换为tuple
str_data = 'hello'
byt_data = b'123'
list_data = [1,2,3]
tuple_data1 = tuple(str_data)
tuple_data2 = tuple(byt_data)
tuple_data3 = tuple(list_data)
print(tuple_data1)
print(tuple_data2)
print(tuple_data3)
D:pythonpython.exe D:/python/python_code/var_cod.py
('h', 'e', 'l', 'l', 'o')
(49, 50, 51)
(1, 2, 3)
Process finished with exit code 0
将除list之外的序列转换为list
str_data = 'hello' byt_data = b'123' tuple_data = (1,2,3) list_data1 = list(str_data) list_data2 = list(byt_data) list_data3 = list(tuple_data) print(list_data1) print(list_data2) print(list_data3) D:pythonpython.exe D:/python/python_code/var_cod.py ['h', 'e', 'l', 'l', 'o'] [49, 50, 51] [1, 2, 3] Process finished with exit code 04.tuple中有哪些操作方法
def count(self, *args, **kwargs): # real signature unknown
""" Return number of occurrences of value. """
pass
def index(self, *args, **kwargs): # real signature unknown
"""
Return first index of value.
Raises ValueError if the value is not present.
"""
pass
5.list中有哪些操作方法
class list(object):
"""
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list.
The argument must be an iterable if specified.
"""
def append(self, *args, **kwargs): # real signature unknown
""" Append object to the end of the list. """
pass
def clear(self, *args, **kwargs): # real signature unknown
""" Remove all items from list. """
pass
def copy(self, *args, **kwargs): # real signature unknown
""" Return a shallow copy of the list. """
pass
def count(self, *args, **kwargs): # real signature unknown
""" Return number of occurrences of value. """
pass
def extend(self, *args, **kwargs): # real signature unknown
""" Extend list by appending elements from the iterable. """
pass
def index(self, *args, **kwargs): # real signature unknown
"""
Return first index of value.
Raises ValueError if the value is not present.
"""
pass
def insert(self, *args, **kwargs): # real signature unknown
""" Insert object before index. """
pass
def pop(self, *args, **kwargs): # real signature unknown
"""
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
"""
pass
def remove(self, *args, **kwargs): # real signature unknown
"""
Remove first occurrence of value.
Raises ValueError if the value is not present.
"""
pass
def reverse(self, *args, **kwargs): # real signature unknown
""" Reverse *IN PLACE*. """
pass
def sort(self, *args, **kwargs): # real signature unknown
"""
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them,
ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
"""
pass



