当我按列表中的发送短信按钮时,出现以下错误。
以10为底的int()的无效文字。
@classmethod
@ModelView.button
def send_sms(cls, donation_records):
for record in donation_records:
record.save()
msg_send = record.notify_user_sms('send_sms')
def notify_user_sms(self, message_state):
if self.dental_pnumber:
if not self.dental_pnumber:
self.raise_user_error("Missing Patient Contact Number.")
contact_to_patient = getattr(self, self.SMS.get(message_state)[0])
params = {
# 'msg': 'This is a testing message. Please ignore it.',
'msg': self.SMS.get(message_state)[1],
'mobile': self.dental_pnumber,
}
url = "http://xxx.xxx.xxx.xx/xxxxsms/xxxxsms.aspx"
requests.get(url, xxxxx)
return True
答案 0 :(得分:0)
编辑: 类型为int的变量具有一个“。”在里面。您应该改用float类型,该类型可以处理“。”。
例如:
import java.util.*;
public class Main {
public static void main(String[] args) {
int[] anArray = { 1, 2, 3, 4, 3, 1, 7, 2, 9, 1, 1, 2 };
java.util.Arrays.sort(anArray);
System.out.println(Arrays.toString(anArray));
int countedElement = anArray[0]; // has the checked element
int count = 0;
for (int i = 1; i < anArray.length - 1; i++) {
if (countedElement == anArray[i] && anArray[i] != anArray[i + 1]) {
count++;
} else {
countedElement = anArray[i];
}
}
System.out.println(count);
}
}
和:
int('99999.000000')
ValueError: invalid literal for int() with base 10
但是,如果您仍然想要int输出,则应使用:
float('99999.000000')
99999.0