alex

day02练习

£可爱£侵袭症+ 提交于 2019-11-27 12:57:27
# name = input("请输入你的名字:")# age = int(input("请输入你的年龄:"))# msg = '''# ------- %s 的博客 -------# Name : %s# Age : %s# -------------------------# ''' % (name, name, age)# print(msg)# 小作业,判断敏感词汇# print(2**24)# s = input(">>>")# if not s:# print("不能为空")# else:# pass# a = "sflsjfslfjslfsjfs"# a1 = a.split('s')# print(a1)# a = "\noldboy\t"# a1 = a.strip()# print(a)# print(a1)# a = 'addoldboydb'# a1 = a.strip("addbd")# print(a)# print(a1)# s = 'oldBoy'# s1 = s.capitalize()# print(s)# print(s1)# s2 =s.swapcase()# print(s2)# s3 = s.upper()# s4 = s.lower()# print(s3,s4)# L1 = ['alex','wusir','太白',100,'女神']

How to use an Alex monadic lexer with Happy?

懵懂的女人 提交于 2019-11-27 02:45:30
问题 I'm trying to learn using Alex + Happy to build parser, in particular I'm interested in learning to use the monad wrapper of Alex. I have already looked at the documentation of Alex and Happy but I they are both, for me, really lacking any useful information on using them together. I managed to make them work together with the basic and posn wrappers, but I'm at a loss with monad . I have already looked at different question on SO about Alex, Happy and monadic lexers (including: Are there any

字典dict的基本用法

风流意气都作罢 提交于 2019-11-26 17:19:57
1. dict 用大括号{} 括起来. 内部使用key:value的形式来保存数据 {'jay':'周杰伦', "jj":'林俊杰'} 注意:字典的key必须是可哈希的. 不可变的, value 没有限制 不是按照我们保存的顺序保存的, 无序的 2. 增删改查 1. 增:dict[不存在的key] = value, setdefault() dic = {} dic[ 'name' ] = ' 周润发 ' # 如果 dict 中没有出现这个 key, 就会新增⼀个 key-value的组合进 dict dic[ 'age' ] = 18 print (dic) # 如果 dict 中没有出现过这个 key-value. 可以通过 setdefault 设置默认值 dic.setdefault( ' 李嘉诚 ' ) # 也可以往⾥⾯设置值 . dic.setdefault( " 李嘉诚 " , " 房地产 " ) # 如果 dict 中已经存在了 . 那么 setdefault将不会 起作⽤ print (dic) 2. 删:pop(key). del dict[key]. popitem(), clear() dic = {"牌牌":"你去哪里了", "晓雪":"你快回来.", "雪雪": "又走了"} ret = dic.pop("晓雪") # 删除一个元素.