xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

資源簡介

python 計(jì)算器示例(入門級(jí),實(shí)現(xiàn)了加減乘除等功能)

資源截圖

代碼片段和文件信息

#!/usr/bin/env?python
#?-*-?coding:utf-8?-*-
#?Author?:?QiuMeng
print(“歡迎使用計(jì)算機(jī)“)
?
import?re

def?replace_func(FormulaChunk):
????‘‘‘
????#去除一些會(huì)影響運(yùn)算的符號(hào)
????:param?FormulaChunk:?#傳入一個(gè)去除括號(hào)后的字符串
????:return:?去除這些東西后標(biāo)準(zhǔn)的返回
????‘‘‘
????FormulaChunk?=?FormulaChunk.replace(“?“““)
????FormulaChunk?=?FormulaChunk.replace(“+-““-“)
????FormulaChunk?=?FormulaChunk.replace(“--““+“)
????return?FormulaChunk



def?mul_and_div(CombineHandlerList):
????‘‘‘
????計(jì)算乘法,除法
????:return:返回一個(gè)沒有任何“*/“字符的列表
????‘‘‘
????ChunkPartitionList?=?CombineHandlerList[1]
????for?indexitem?in?enumerate(ChunkPartitionList):
????????if?“*“?in?item?or?“/“?in?item:??#?判斷這個(gè)元素中是否有“*/“
????????????OperatorList?=?re.findall(“[*/]“item)??#?分割出乘除號(hào)
????????????PartitionList?=?re.split(“[*/]“item)???#?根據(jù)乘除分割
????????????SumCount?=?None
????????????for?ij?in?enumerate(PartitionList):
????????????????if?SumCount:??#第一個(gè)元素不計(jì)算
????????????????????if?OperatorList[i-1]?==?“*“:??#?算乘法
??????????????????

評(píng)論

共有 條評(píng)論

相關(guān)資源