[英]unsupported operand types in python
以下是我用於使用Python(硒)拍攝屏幕截圖的代碼
path = os.mkdir('D:\screenshots' + time.strftime("%d%m"))
driver.get_screenshot_as_file(path + '\wishlist_' + str(i) + '.jpg')
但是,當我運行此程序時,出現以下錯誤,
追溯(最近一次通話):文件“ C:\\ Users \\ me \\ Desktop \\ domain.py”,第43行,在test_bkpdomains中
driver.get_screenshot_as_file(path + '\wishlist_' + str(i) + '.jpg')
TypeError:+不支持的操作數類型:“ NoneType”和“ str”
任何人都可以幫助我克服這個困難嗎?
您正在嘗試將空對象與第二行中的字符串連接起來。
例如,
import os
path = os.mkdir('dummy')
print path
返回None
因此您無法將其與第二行中的字符串結合使用。 也許如果您創建目錄,然后僅在第二行中使用字符串作為其路徑:
path = '/path/to/directory' #string for usage below (can be concatenated)
os.mkdir(path) #make the actual directory
driver.get_screenshot_as_file(path + '/wishlist_' + str(i) + '.jpg')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.