1. 面向?qū)ο蟾袷?/h3>
class onesection:
name = '123'
key = None
value = None
def fail_in_the_blank():
logger.info('123')
t1 = onesection()
t1.name = '234'
2. dictionary
d.clear() #清空
d.keys() #返回list
d.values() #返回list
d.items() #返回list
3. 二維數(shù)組
nums_battery_weight = [[None] * 3] * 3 #申請(qǐng)三組內(nèi)存空間一樣的,一組三個(gè)None的數(shù)組
nums_battery_weight = [[] * 3] * 3 #申請(qǐng)三組內(nèi)存空間一樣的郑气,一組三個(gè)None的數(shù)組
nums_battery_weight = [[None] * 3 , [None] * 3 , [None] * 3] #申請(qǐng)三組內(nèi)存空間不同的幅垮,一組三個(gè)None的數(shù)組
4. 日志模塊
import logging
logger.basicConfig(level=logging.INFO)
logger = logger.getLogger(__name__)
logger.info('print logger')
logger.debug('not show')
5.字符串處理
str.lstrip() #去除左邊
str.rstrip() #去除右邊
str.strip() #去除兩邊
#string與list互轉(zhuǎn)
str_list = [
str1,
str2,
str3
]
str_all = ''.join(str_list)
str = 'abcde'
list_str = list(str)
list
['a','b','c','d','e']
6. 字符串轉(zhuǎn)數(shù)字
str_int = '123'
str_float = '1.23'
num_int = int(str_int)
num_float = float(str_float)
class onesection:
name = '123'
key = None
value = None
def fail_in_the_blank():
logger.info('123')
t1 = onesection()
t1.name = '234'
d.clear() #清空
d.keys() #返回list
d.values() #返回list
d.items() #返回list
nums_battery_weight = [[None] * 3] * 3 #申請(qǐng)三組內(nèi)存空間一樣的,一組三個(gè)None的數(shù)組
nums_battery_weight = [[] * 3] * 3 #申請(qǐng)三組內(nèi)存空間一樣的郑气,一組三個(gè)None的數(shù)組
nums_battery_weight = [[None] * 3 , [None] * 3 , [None] * 3] #申請(qǐng)三組內(nèi)存空間不同的幅垮,一組三個(gè)None的數(shù)組
import logging
logger.basicConfig(level=logging.INFO)
logger = logger.getLogger(__name__)
logger.info('print logger')
logger.debug('not show')
str.lstrip() #去除左邊
str.rstrip() #去除右邊
str.strip() #去除兩邊
#string與list互轉(zhuǎn)
str_list = [
str1,
str2,
str3
]
str_all = ''.join(str_list)
str = 'abcde'
list_str = list(str)
list
['a','b','c','d','e']
str_int = '123'
str_float = '1.23'
num_int = int(str_int)
num_float = float(str_float)