首页 > 编程知识 正文

python实时投票系统的简单介绍

时间:2023-12-15 19:09:11 阅读:316114 作者:YUSK

本文目录一览:

如何用python实现网络上的自动投票功能

网络投票大都采用post方法,因此我们可以分析post的url,对具体的post参数进行分析,通过requests模块,进行提交就行了。需要注意的是大部分网站可能存在ip地址限制,或者浏览器限制等情况,所以需要设计代理和ua列表进行投票,避免被屏蔽。

如何用Python来做一个投票app?

app?你要做手机上的还是网页的?

推荐你看《深入浅出python》的后面几章,讲cgi和android的。如果你是要做网页的,可以看web.py或者django

python新手求助 写一个投票的代码 def vote() 有三种,yes,no,abstain

def vote(stra):

yesstr=['yes','y']

nostr=['no','n']

abstainedstr=['abstained','a']

count=0

yescount=0

stra=stra.replace(',',' ')

for i in stra.split():

lowerstr=i.lower()

if lowerstr in yesstr:

yescount+=1

count+=1

elif lowerstr in nostr:

count+=1

if yescount==count:

return 'proposal passes unanimously'

if yescount*1.0/count=2.0/3.0:

return 'proposal passes with super majority'

if yescount*1.0/count=0.5:

return 'proposal passes with simple majority'

return 'proposal fails'

if __name__=='__main__':

stra=raw_input('Enter the yes,no,abstained votes one by one and the press enter:n')

print vote(stra)

python如何编一个投票系统

LI = ['张三','李四','刘五']

def inputs(prompt, selectlist, eof='EOF'):

    while True:

        choice = raw_input(prompt)

        if choice == eof:

            break

        elif choice in selectlist:

            yield choice

        else:

            print "only in %s" % selectlist

collects = map(None, inputs("投票", LI, eof='投票结束'))

# by dict

counter = {}

for name in collects:

    counter[name] = counter.get(name,0)+1

for name, c in sorted(counter.items(), key=lambda x:x[1], reverse=True):

    print name, c

# by collections.Counter

import collections

counter = collections.Counter(collects)

for name, c in counter.most_common(10):

    print name, c

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。