我正在尝试在 Pycharm 中运行此代码,但出现以下错误:
TypeError: expected str, bytes or os.PathLike object, not NoneType
Run Code Online (Sandbox Code Playgroud)
这适用于 Windows 10,在 Pycharm 上运行,python 3.7
import os
import time
file_path = os.path.join(os.getenv("HOME"), "birth_day_lookup.txt")
def check_birthday():
lookup_file = open(file_path, 'r')
today = time.strftime('%d-%B')
flag = 0
for entry in lookup_file:
if today in entry:
line = entry.split(' ')
flag = 1
os.system('notify-send "Today is '+line[1]+' '+line[2]+'\'s Birthday"')
if flag == 0:
os.system('notify-send "No birthday for today is listed"')
check_birthday()
Run Code Online (Sandbox Code Playgroud)