• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python stack.Stack类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pythonds.basic.stack.Stack的典型用法代码示例。如果您正苦于以下问题:Python Stack类的具体用法?Python Stack怎么用?Python Stack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Stack类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: chkid_allrecord

	def chkid_allrecord(self,m,rr1):
			# que = "SELECT * FROM wp_2015ptainsuracelist where frm_id='%s';" % (rr1)
			# rr=m.db.query(que)
			idData = (str(rr1),)
			que = """SELECT * FROM """+self.table+""" where frm_id==?"""
			rr=m.dbsql3.data_query(que,idData,False)
			print rr
			p = Stack()
			print(rr)
			if rr:
				for i in rr[0]:
					p.push(i)
				rrr=p.seek()
				OR = rrr[18]
				ins = rrr[16]
				reg = rrr[15]
				trans = rrr[19]
				print "Pass chkid_allrecord!******************"
				if OR=='' and ins==0 and reg==0 and trans=='':
					return 'False1',rrr
				if OR!='' and ins==0 and trans!='':
					return 'True1',rrr
				if OR!='' and ins!=0 and trans!='':
					return 'True2',rrr
			else:
				return 'False2'
开发者ID:maestrom4,项目名称:must-pta2,代码行数:26,代码来源:func.py


示例2: chkid_len

	def chkid_len(self,main,a,b=None,c=None,d=None,e=False):

		if e:
			if len(a)==8 or len(a)==10 or a.count('x')==4:
				return True
			else:
				self.alert(main,'ID Less than 8 or 10!','ID length allowed is 8 or 10 \n You have #'+str(len(a))+' digits.')
				return False
		else:
			print("self table===="+self.table)
			print("Check by name is activated!")
			# que = "SELECT * FROM wp_2015ptainsuracelist where frm_stdname='%s' AND frm_std_middle_name='%s' AND frm_std_last_name='%s';" % (b,c,d)
			que = """SELECT * FROM """+self.table+""" where frm_stdname=? AND frm_std_middle_name=? AND frm_std_last_name=?"""
			fullname = (str(b),str(c),str(d))
			rr=main.dbsql3.data_query(que,fullname)
			p = Stack()
			print(b+" "+c+" "+d)
			print("student name! search")
			print(rr)
			if rr:
				for i in rr[0]:
					p.push(i)
				rrr=p.seek()
				OR = rrr[18]
				ins = rrr[16]
				reg = rrr[15]
				trans = rrr[19]
				if OR=='' and ins==0 and reg==0 and trans=='':
					return 'False1'
				if OR!='' and ins==0 and trans!='':
					return 'True1',rrr
				if OR!='' and ins!=0 and trans!='':
					return 'True2',rrr
			else:
				return 'False2'
开发者ID:maestrom4,项目名称:must-pta2,代码行数:35,代码来源:func.py


示例3: revstring_mine

def revstring_mine(mystr):
    s = Stack()
    for char in mystr:
        s.push(char)
    revstr = ''
    while not s.isEmpty():
        revstr += s.pop()
    return revstr
开发者ID:xkal36,项目名称:Algorithms,代码行数:8,代码来源:string_reversal_stack.py


示例4: revstring

def revstring(mystr):
	s = Stack()
	new_mystr = ''
	for i in mystr:
		s.push(i)
	while not s.isEmpty():
		new_mystr = new_mystr+s.pop()
	return new_mystr
开发者ID:yuelingjiang,项目名称:workspace,代码行数:8,代码来源:algorithm2.py


示例5: revstring

def revstring(mystr):
    myStack = Stack()
    for i in mystr:
      myStack.push(i)
      revstr = ''
    while not myStack.isEmpty():
      revstr = revstr + myStack.pop()
    return revstr
开发者ID:bradleyscot,项目名称:cookbook,代码行数:8,代码来源:reverse_string.py


示例6: revstring

def revstring(mystr):
    # your code here
    reversed = ""
    string_stack = Stack()
    for char in mystr:
        string_stack.push(char)
    while not string_stack.isEmpty():
        last = string_stack.pop()
        reversed += last
    return reversed
开发者ID:cforan99,项目名称:challenges,代码行数:10,代码来源:revstr_stack.py


示例7: match_parenthesis

def match_parenthesis (symbolString):
  ## close any and all open parenthesises & return a "file" to be processed further... 
  from pythonds.basic.stack import Stack
  s = Stack()
  balanced = True
  index = 0
  while index < len(symbolString) and balanced:
        symbol = symbolString[index]
        if symbol == "(":
            s.push(symbol+ str(index))
        elif symbol == ")":
            if s.isEmpty():
                balanced = False
            else:
                s.pop()

        index = index + 1

  if balanced and s.isEmpty():
        #print ("it is FINALLY balanced!")
        return symbolString
  elif balanced and not s.isEmpty():
        #print "opening barace is not closed at " 
        
        idx = int (s.pop().strip("("))
        #print idx
        #print symbolString[idx]
        return (match_parenthesis(removeExtra(symbolString,idx))) 
  else:   #couldn't pop from stack
        #print "extra closing present at"
        #print index
        return (match_parenthesis(removeExtra(symbolString,index-1))) 
开发者ID:tanksha,项目名称:external-tools,代码行数:32,代码来源:sumo-importer.py


示例8: buildParseTree

def buildParseTree(fpexp):
    fplist = fpexp.split()
    pStack = Stack()
    eTree = BinaryTree('')
    pStack.push(eTree)
    currentTree = eTree
    for i in fplist:
        if i == '(':            
            currentTree.insertLeft('')
            pStack.push(currentTree)
            currentTree = currentTree.getLeftChild()
        elif i not in ['+', '-', '*', '/', ')']:  
            currentTree.setRootVal(int(i))
            parent = pStack.pop()
            currentTree = parent
        elif i in ['+', '-', '*', '/']:       
            currentTree.setRootVal(i)
            currentTree.insertRight('')
            pStack.push(currentTree)
            currentTree = currentTree.getRightChild()
        elif i == ')':          
            currentTree = pStack.pop()
        else:
            raise ValueError
    return eTree
开发者ID:ErikRHanson,项目名称:Problem-Solving-with-Algorithms-and-Data-Structures-Using-Python,代码行数:25,代码来源:parsetree.py


示例9: buildParseTree

def buildParseTree(fpexp):
    fplist = fpexp.split()
    pStack = Stack()
    eTree = BinaryTree("")
    pStack.push(eTree)
    currentTree = eTree
    for i in fplist:
        if i == "(":
            currentTree.insertLeft("")
            pStack.push(currentTree)
            currentTree = currentTree.getLeftChild()
        elif i not in ["+", "-", "*", "/", ")"]:
            currentTree.setRootVal(int(i))
            parent = pStack.pop()
            currentTree = parent
        elif i in ["+", "-", "*", "/"]:
            currentTree.setRootVal(i)
            currentTree.insertRight("")
            pStack.push(currentTree)
            currentTree = currentTree.getRightChild()
        elif i == ")":
            currentTree = pStack.pop()
        else:
            raise ValueError
    return eTree
开发者ID:arunkamaraj,项目名称:learning,代码行数:25,代码来源:tree_trial.py


示例10: match_parenthesis

def match_parenthesis(symbolString):
    ## close any and all open parenthesises & return a "file" to be processed further... 
    from pythonds.basic.stack import Stack
    s = Stack()
    balanced = True
    index = 0
    while index < len(symbolString) and balanced:
        symbol = symbolString[index]
        if symbol == "(":
            s.push(symbol+ str(index))
        elif symbol == ")":
            if s.isEmpty():
                balanced = False
            else:
                s.pop()

        index = index + 1

    if balanced and s.isEmpty():
        return symbolString
    elif balanced and not s.isEmpty():
        idx = int (s.pop().strip("("))
        return (match_parenthesis(removeExtra(symbolString,idx)))
    else:   #couldn't pop from stack
        return (match_parenthesis(removeExtra(symbolString,index-1)))
开发者ID:TScottJ,项目名称:external-tools,代码行数:25,代码来源:kifparser.py


示例11: divide_by_2

def divide_by_2(num):
    rem_stack = Stack() # putting my stack in action

    while num > 0:
        rem = num % 2 # remainder variable
        rem_stack.push(rem) # push the remainder in my stack
        num = num // 2 # divide my num by two

    bin_string = '' # create my binary string
    while not rem_stack.isEmpty():
        bin_string = bin_string + str(rem_stack.pop()) # pop the remainder from my stack
    return bin_string # get my binary string
开发者ID:Martondegz,项目名称:python-snippets,代码行数:12,代码来源:binary.py


示例12: revString

def revString(astring):
    s = Stack() #create a new stack
    
    for ch in astring:
        s.push(ch)
    
    reverse_string = ''

    for i in range(len(astring)):
        reverse_string = reverse_string + s.pop()
        
    return reverse_string
开发者ID:herokyar,项目名称:algorithms_Python,代码行数:12,代码来源:reverse_string_by_stack.py


示例13: divide_by_two

def divide_by_two(decimal):
    stack = Stack()

    while decimal > 0:
        remainder = decimal % 2
        stack.push(remainder)
        decimal = decimal // 2

    binary = ''
    while not stack.isEmpty():
        binary += str(stack.pop())

    return binary
开发者ID:arosenberg01,项目名称:toy-problems,代码行数:13,代码来源:decimal-to-binary.py


示例14: divideBy2

def divideBy2(decNumber):
    remstack = Stack()

    while decNumber > 0:
        rem = decNumber % 2
        remstack.push(rem)
        decNumber = decNumber // 2

    binString = ""
    while not remstack.isEmpty():
        binString = binString + str(remstack.pop())

    return binString
开发者ID:teddymcw,项目名称:pythonds_algos,代码行数:13,代码来源:stacks.py


示例15: revstring

def revstring(sg):
    s = Stack()

    lst = [i for i in sg]
    res = []

    for c in lst:
        s.push(c)

    while not s.isEmpty():
        res.append(s.pop())

    return "".join(res)
开发者ID:gr8h,项目名称:competitive_programming_py,代码行数:13,代码来源:revstring.py


示例16: baseConverter

def baseConverter(decNumber, base):
	digits = '0123456789ABCDEF'
	remstack = Stack()

	while decNumber > 0:
		rem = decNumber % base
		remstack.push(rem)
		decNumber = decNumber // base
		
	newString = ''

	while not remstack.isEmpty():
		newString = newString + digits[remstack.pop()]
	return newString
开发者ID:yuelingjiang,项目名称:workspace,代码行数:14,代码来源:algorithm2.py


示例17: baseConverter

def baseConverter(decNumber, base):
    digits = string.digits + string.uppercase
    s = Stack()

    while decNumber > 0:
        rem = decNumber % base
        s.push(rem)
        decNumber /= base

    res = []
    while not s.isEmpty():
        res.append(str(digits[s.pop()]))

    return "".join(res)
开发者ID:gr8h,项目名称:competitive_programming_py,代码行数:14,代码来源:revstring.py


示例18: divideBy2

def divideBy2(decNumber):
    s = Stack()

    while decNumber > 0:
        rem = decNumber % 2
        s.push(rem)

        decNumber //= 2

    res = []
    while not s.isEmpty():
        res.append(str(s.pop()))

    return "".join(res)
开发者ID:gr8h,项目名称:competitive_programming_py,代码行数:14,代码来源:revstring.py


示例19: chkDate_allRec

	def chkDate_allRec(self,m,a,camp):

		# que = "SELECT * FROM wp_2015ptainsuracelist where frm_time_date='%s';" % (a)
		# rr=m.db.query(que)
		dateData = (str(a),)
		que = """SELECT * FROM """+self.table+""" where frm_time_date==?"""
		rr=m.dbsql3.data_query(que,dateData,False)
		# print(rr)
		y = Stack()
		p= []
		str2=[]
		if rr:
			for i in rr:

				print(i)
				# OR = i[18]
				# ins = i[16]
				# reg = i[15]
				# trans = i[19]
				#
				if i[18]!='' and i[15]!=0 and i[16]!=0 and i[19]!='' and i[20]==camp:
					y.push(list(i))
				#Has a sibling and paid the insurance fee
				if i[18]!='' and i[15]==0 and i[16]!=0 and i[19]!='' and i[20]==camp:
					y.push(list(i))
				#declared but not insured
				if i[18]!='' and i[15]==0 and i[16]==0 and i[19]!='' and i[20]==camp:
					y.push(list(i))
			return True,y.seek()

			# ns!='':
				# return 'True2',rrr

		else:
			return False
开发者ID:maestrom4,项目名称:must-pta2,代码行数:35,代码来源:func.py


示例20: baseConverter

def baseConverter(decNumber,base):
	digits = "0123456789ABCDEF"
	remstack = Stack()

	while decNumber > 0:
		rem = decNumber % base
		remstack.push(rem)
		decNumber = decNumber // base


	binString =''
	while not remstack.isEmpty():
		binString += digits[(remstack.pop())]


	return binString
开发者ID:andersy005,项目名称:Python-Quest,代码行数:16,代码来源:BaseConverter.py



注:本文中的pythonds.basic.stack.Stack类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pythonect.eval函数代码示例发布时间:2022-05-27
下一篇:
Python pythoncom._GetInterfaceCount函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap