小编Jot*_*ani的帖子

如何计算python中的百分比

这是我的计划

print" Welcome to NLC Boys Hr. Sec. School "
a=input("\nEnter the Tamil marks :")
b=input("\nEnter the English marks :")
c=input("\nEnter the Maths marks :")
d=input("\nEnter the Science marks :")
e=input("\nEnter the Social science marks :")
tota=a+b+c+d+e
print"Total is: ", tota
per=float(tota)*(100/500)
print "Percentage is: ",per
Run Code Online (Sandbox Code Playgroud)

结果

Welcome to NLC Boys Hr. Sec. School 

Enter the Tamil marks :78

Enter the English marks :98

Enter the Maths marks :56

Enter the Science marks :65

Enter the Social science marks :78 …
Run Code Online (Sandbox Code Playgroud)

python percentage python-2.7

9
推荐指数
3
解决办法
8万
查看次数

从元组列表中获取最接近给定值的元组

给定一个包含坐标的元组列表,我想找到哪个坐标最接近我在输入中给出的坐标:

cooList = [(11.6702634, 72.313323), (31.67342698, 78.465323)]
coordinate = (11.6702698, 78.113323)
takenearest(myList, myNumber)
...
(11.6702634, 72.313323)
Run Code Online (Sandbox Code Playgroud)

请告诉我...

python tuples list coordinates

1
推荐指数
1
解决办法
3328
查看次数

Python: - 从电子邮件列表中拆分电子邮件(逗号,空格分隔)

我的意见是

email_list = 

"mail1@mail.com,mail2@mail.com, mail3@mail.com mail4@mail.com 
mail5@mail.com"
Run Code Online (Sandbox Code Playgroud)

例外输出是

['mail1@mail.com', 'mail2@mail.com', 'mail3@mail.com', 'mail4@mail.com', 'mail5@mail.com']
Run Code Online (Sandbox Code Playgroud)

我试过这个方法,但它只会拆分(,)分开.请告诉我.

output = email_list.split(',') 
Run Code Online (Sandbox Code Playgroud)

提前致谢...

python string list

1
推荐指数
1
解决办法
1158
查看次数

psycopg2.ProgrammingError:"st"\ r \n附近的语法错误,

在这里,我需要在python中的postgresql表中插入一些值.

我尝试下面的代码,但一个错误是"psycopg2.ProgrammingError:语法错误在或附近"st"\ r,referer:http:// localhost:8080 / "

conn = psycopg2.connect(database="Test", user="dev", password="123456", host="192.168.1.104", port="5432")
cursor = conn.cursor()

cursor.execute('''INSERT INTO signup (id, name, email, dob, address, mobile, password) VALUES (1,%s,%s,%s,%s,%s,%s)''' % (name,email,dob,address,mobile,password))
conn.commit()
Run Code Online (Sandbox Code Playgroud)

请解决这个问题,提前谢谢.....

python psycopg2 insert

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×4

list ×2

coordinates ×1

insert ×1

percentage ×1

psycopg2 ×1

python-2.7 ×1

string ×1

tuples ×1