![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python基础
飒律自人
危机感,人死于“习惯”
展开
-
Python进制转换(栈)
输入格式 (被转数+目的进制)from pythonds.basic.stack import Stackdef baseConverter(number, base): dights="0123456789ABCDEF" s = Stack()#括号不能丢,创建空栈 while number>0: x = number % base s.push(x) number = number // base#整除 nstr原创 2021-03-22 22:42:47 · 265 阅读 · 0 评论 -
Python 用栈实现括号匹配
导包:from pythonds.basic.stack import Stack匹配“(){{}}[]”不匹配“{](}”“{{{{}”from pythonds.basic.stack import Stackdef parChecker(symbolString): s = Stack() ok = True index = 0 while index < len(symbolString) and ok: x = symbolStrin原创 2021-03-18 22:39:58 · 273 阅读 · 0 评论 -
Python进行字符串的回文判定
核心思想:切片反转记录第一天python编程。真是优雅简洁,摆脱细枝末节,发际线终于……该掉还得掉????word = input()fword=word[::-1]#字符串反转if(fword==word): print("Yes")else: print("No")原创 2021-03-16 22:23:16 · 313 阅读 · 0 评论