執行函數

from math import sqrtwith open('prime.txt', 'w') as f:
for num in range(2, 100):
if is_prime(num):
f.write(str(num) + '\n')
print('写入完成!')

找尋字串是否包含於條件中

birth = input('请输入你的生日: ')
with open('pi_million_digits.txt') as f:
lines = f.readlines()
pi_string = ''
for line in lines:
pi_string += line.strip()
if birth in pi_string:
print('Bingo!!!')

Written by

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store