Python的三种逻辑控制 1.python语法. python 是以缩进作为基本判断的.同一代码缩进需要保持一致.否则会报错 1.if 的三种循环 _age = 53 # 注意,input接受的都是字符串,如果要和数字比较大小,需要转化为int age = int(input("age:") ) if age > _age : print("大于实际年龄") age = int(input("age:") ) if age > _a…
# -*-coding:utf-8-*- def test(content): text = content flag = 0 with open('filtered_words.txt') as fp: for line in fp.readlines(): text = text.replace(line.strip('\n'),'**') # print text #print text fp.close() print text if __name__ == '__main__': te…
1 # -*-coding:utf-8-*- 2 3 4 def test(content): 5 flag = 0 6 with open('filtered_words.txt') as fp: 7 for line in fp.readlines(): 8 if line.strip('\n') in content: 9 flag = 1 10 else: 11 pass 12 13 if flag == 1: 14 print "Freedom" 15 else : 16 p…