标签:not 用户 [] strip please pen name generator filename
def check_file(filename, content): with open(filename, encoding=‘utf-8‘) as f: for i in f: if content in i: yield i g = check_file(‘file‘, ‘火‘) for i in g: print(i.strip())
def generator(): with open(‘file‘, encoding=‘utf-8‘) as f: for i in f: yield ‘***‘ + i g = generator() for i in g: print(i.strip())
li = [1, 2, 3, 4, 2, 5, 4, 8] lis = [] for i in li: if i not in lis: lis.append(i) li = lis print(li)
num_1 = 1 # 第一个数 num_2 = 1 # 第二个数 count = 2 while num_1 + num_2 < 4000000: sum = num_1 + num_2 # 前两个数之和等于第三个数 num_1 = num_2 # 把第二个数赋值给num_1 num_2 = sum # 把第三个数赋值给num_2 count += 1 print(‘400万以内最大的斐波那契数是{},它是第{}个斐波那契数‘.format(sum, count))
price = int(input(‘please tell me goods price:‘)) if price >= 50 and price <= 100: print(‘您的商品打9折,你需要支付{}元‘ .format(price * 0.9)) elif price > 100: print(‘您的商品打8折,你需要支付{}元‘ .format(price * 0.8)) else: print(‘你需要支付{}元‘ .format(price))
标签:not 用户 [] strip please pen name generator filename
原文地址:https://www.cnblogs.com/lin961234478/p/10675490.html