㈠ python语言写的一个小程序
可能会有的错误:
OverflowError: Python int too large to convert to C long
或者
OverflowError: range() result has too many items
,python的Int无限制,但C的int和long都会溢出,因为python的很多函数底层用C实现的,所以python有时也会出现这种错误,解决办法就是不要使用这些函数,改进算法,用别的函数
在需要用for x in range(很大的整数) 来写循环时, 用while 来代替
㈡ python编一段小程序
phonebook={
'Alice':{
'phone':'2341',
'addr':'Foodrive23'
},
'Beth':{
'phone':'1213',
'addr':'Bazavenue90'
},
'Ceil':{
'phone':'3219',
'addr':'Bazavenue90'
}
}
key=input("请输入您要查找的姓名:")
#forkeyinphonebook:
ifkeyinphonebook.keys():
print(phonebook[key])
else:
print("没有",key,'的信息')
#用python3.4改的,个别函数可以自行替换
㈢ 用python编写一个小程序
definput_1():
a=raw_input('Pleaseinputsomething: ')
globalst
st=list(a)
print'Nowthelistyoujustinputtedis: ',st
success=True
whilesuccess:
input_1()
foriinst:
c=st.count(i)
ifc>=3:
print'Youlost!'
print'Error:Thenumberof%syoujustinputis%s'%(i,c)
success=True
break
print'Thenumberof%syouinputtedis%stime(s)'%(i,c)
success=False
print'Success!'
㈣ 推荐几个适合新手练手的Python项目
《Python实战:四周实现爬虫系统》网络网盘免费下载
链接:
Python实战:四周实现爬虫系统
㈤ 帮用python做个小程序
我也是刚学python,下面是我的程序,试了下,大致没问题。
def print_title(seq):
seq_len = len(seq)
screen_width = 80
box_width = seq_len + 6
left_margin = (screen_width - box_width) // 2
print()
print(' '*left_margin + '+' + '-'*(box_width-2) + '+')
print(' '*left_margin + '|' + ' '*(box_width-2) + '|')
print(' '*left_margin + '|' + ' ' + seq + ' ' + '|')
print(' '*left_margin + '|' + ' '*(box_width-2) + '|')
print(' '*left_margin + '+' + '-'*(box_width-2) + '+')
print()
def continue_or_not():
while (True):
flag = input("continue?(Y/N)")
if (flag.lower() == 'y') : return True
elif (flag.lower() == 'n') : return False
else : print("Invalid input :", flag)
def show_menu():
print("Menu:")
print("(I)nstructions")
print("(P)lay Game")
print("(Q)uit")
print()
import random
def guess_num():
target_num = int( random.random()*42 ) + 1
count = 0
while (True):
guess_num = int( input("Please enter you guess(1---42): ") )
print("guess_num = ", guess_num)
if ( (guess_num < 1) | (guess_num > 42)) :
print("invalid guess")
count += 1
continue
if (guess_num == target_num) :
print("You got it!")
break
elif (guess_num < target_num) :
print("My number is higher")
count += 1
continue
else :
print("My number is lower")
count += 1
continue
return count
print_title("Welcome to the Great CP1200 Guessing Game!")
print("Written by Lindsay Ward, March 2011 ")
name = input("What is your name? ")
while (True):
show_menu()
choice = input()
if (choice.lower() == 'i'):
print("I pick a number and you have to guess it. ")
print("Try and get it in as few guesses as possible.")
print()
continue
elif (choice.lower() == 'p'):
guess_count = guess_num()
print("Well done!", name, "You guessed it in", guess_count, "guesses")
break
elif (choice.lower() == 'q'):
break
else :
print("Invalid Menu Choice")
print()
continue
print_title("Thanks for playing")
㈥ 怎样用python 写小程序
你好,python不适合做小程序的。
1、微信官方为小程序提供了大量的接口api ,开发小程序需要有基本的Javascript, HTML , CSS的基础。
2、小程序开发,常见使用"MINA” 框架
Apache Mina Server是一个网络通信应用框架,也就是说,它主要是对基于TCP/IP、UDP/IP协议栈的通信框架(当然,也可以提供JAVA对象的序列化服务、虚拟机管道通信服务等),Mina 可以帮助我们快速开发高性能、高扩展性的网络通信应用, Mina提供了事件驱动、异步( Mina的异步IO默认使用的是JAVA NIO作为底层支持)操作的编程模型。
这个框架为微信小程序的运行提供了丰富的组件和API。要学会和掌握小程序的框架结构、数据绑定机制、模板、数据缓存、常用组件和API等相关知识。
希望对你有帮助!
㈦ 请高手 帮忙使用 python 写一个小程序· 谢谢了··比较急
数百行代码,写出来也不一定让你满意,没人会帮忙的,起码你应该定个框架,自己用默认的模块把简单的登陆神马的弄好,再来问具体模块怎么实现。
(比如选bottle框架,用默认的Cork做登陆,用最简单的sqlite做数据库,你提到了三个类是不是指要用到ORM,如果用ORM你还得研究SQLALCHEMEMY和sqlite的配合,还要设计用户界面也许你会用dojo或jquery,再加上付款用到建行api之类,要考虑太多东西可能要上千行代码。。。)
㈧ 有关python的一个小程序,今天要交作业了。帮帮我
monthNames=['January','February','March','April','May','June','July','August','September','October','November','December']
birthstones=['Garnet','Amethyst','Aquamarine','Diamond','Emerald','Pearl','Ruby','Peridot','Sapphire','Opral','Topaz','Turquoise']
monthstones=dict(zip(monthNames,birthstones))
month=raw_input('enter a month:')
print "the %s's birthstone is %s " %(month,monthstones[month])
㈨ 如何使用python编写一个小程序
foriinrange(100):
ifi%3==0ori%10==3:
printi
㈩ python的一个小程序怎么写
num1 = int(input())
num2 = int(input())
sum_all = 0
for i in range(num1,num2+1):
if i % 3 == 0 or i % 5 == 0:
sum_all += i
print(sum_all)