假設我有一個代碼段如下 r = requests.post(url, data=values, files=files)
由於這是進行網絡請求,一束異常可以從該線被拋出。對於參數的完整性,我也可以有文件讀取,發送電子郵件等。要遇到這樣的錯誤,我做 try:
r = requests.post(url, data=values, files=files)
if r.statu
之後重新輸入try語句在我的代碼中,當我遇到異常時,它停止執行。我怎樣才能讓它重新輸入try聲明中的例外情況?也許我正在尋找不同的方法來解決這個問題,而沒有嘗試除了語句? import requests
from requests import exceptions
contains_analyst = []
try:
for x in data:
r = requ
下面的代碼不起作用: try:
get_current_player(request).cash >= bid # does the player have enough cash for this bid ?
except ValueError:
messages.error(request, "You don't have the necessary funds to p
我讀一個文件,並使用try catch來趕情況下,該數據可能不是我要找的類型: for w in text.readlines():
try:
new = float(w.split()[3].replace(',', '.'))
if new < temp and w.split()[1][3:5] == '12':
temp = new