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

  • 大小: 6.44KB
    文件類型: .py
    金幣: 1
    下載: 0 次
    發布日期: 2021-03-03
  • 語言: Python
  • 標簽: 計算器??計算??

資源簡介

python 計算器示例(入門級,實現了加減乘除等功能)

資源截圖

代碼片段和文件信息

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

def?replace_func(FormulaChunk):
????‘‘‘
????#去除一些會影響運算的符號
????:param?FormulaChunk:?#傳入一個去除括號后的字符串
????:return:?去除這些東西后標準的返回
????‘‘‘
????FormulaChunk?=?FormulaChunk.replace(“?“““)
????FormulaChunk?=?FormulaChunk.replace(“+-““-“)
????FormulaChunk?=?FormulaChunk.replace(“--““+“)
????return?FormulaChunk



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

評論

共有 條評論