简单好玩的python代码
@弘兴1273:求一个简单的Python给数字排序代码 -
延咳18043711608…… 简单排序的话,直接使用 list.sort() 就可以了,直接在原列表上进行排序. 非要写成函数的形式的话,代码如下 1 2 3 4 5 6 7 8 9 defABC(nums_l): nums_l.sort() returnnums_ll =[1,2,5,3,4] # 其实,使用 l.sort() 之后,就对l进行了排序,然...
@弘兴1273:怎么用python编写好玩的程序 -
延咳18043711608…… 猜数游戏.pyimport random, easygui number = random.randint(1, 99) guess = 0 tries = 0 easygui.msgbox("I have a secret, can you guess?It's a number from 1 to 99. I'll give you 7 tries.") while guess != number and tries < 7: guess = easygui....
@弘兴1273:python的一个简单程序 -
延咳18043711608…… #-*- coding:utf-8 -*- name = raw_input('Please enter your name: ') if name == 'Tom': print 'You are great!' else: print 'You input the wrong name!'
@弘兴1273:写一个简单的PYTHON程序,模拟摇一个色子 -
延咳18043711608…… import random def roll_die_once(min = 1, max = 6): """Roll the die once, with min and max given.""" return random.randrange(min, max+1) def main(): """Accept user input as times, then roll the die repeatedly for times given.""" ...
@弘兴1273:求高手帮写个简单的python程序~~ -
延咳18043711608…… def cal(input="input.txt",output="output.txt"): #cal方法为主程序,推荐这样做而不是PYTHON.EXE xx.py xxx xxx.默认参数为python目录的两个txt,如为其他文件自己指定. infile = file(input,"r")#打开源数据文件 outfile = file(output,"w")#打...
@弘兴1273:python代码 -
延咳18043711608…… #! usr/bin/env python # -*- coding: utf-8 -*- import sys def dispaly(ch) : for i in xrange(0,len(ch)-1) : if ch[i] == chr(127) : print chr(ord(ch[i])-1),'none' elif ch[i] == chr(0) : print 'none',chr(ord(ch[i])+1) else : print chr(ord(ch[i])-1),chr(ord(ch[i])+1) if __...
@弘兴1273:求一个简单的Python程序 在线等 -
延咳18043711608…… import random def roll_die_once(min = 1, max = 6):
@弘兴1273:python 编写简单方程 -
延咳18043711608…… 函数名不能有# 所以: #!python3 import re def extract(s): return [i[1:] for i in re.findall(r'#\w+',s)] print(extract('ABC #123ab! #abc')) print(extract('ABC #123ab! #123ab! #abc'))运行结果: [willie@bogon ~]$ python3 Python 3.5.2 (default, Sep 30 ...
@弘兴1273:python3 写个最简单的程序 -
延咳18043711608…… 用split()分割即可 a = input('input a and b') lista = a.split(',') ans = (int)(lista[0]) + (int)(lista[1]) print(ans)
@弘兴1273:python 可以做哪些有趣的 -
延咳18043711608…… Python 可以做什么,这是一个有趣的问题. 从入门级选手到专业级选手都在做的——爬虫 用 Python 写爬虫的教程网上一抓一大把,据我所知很多初学 Python 的人都是使用它编写爬虫程序.小到抓取一个小黄图网站,大到一个互联网公司的商...
延咳18043711608…… 简单排序的话,直接使用 list.sort() 就可以了,直接在原列表上进行排序. 非要写成函数的形式的话,代码如下 1 2 3 4 5 6 7 8 9 defABC(nums_l): nums_l.sort() returnnums_ll =[1,2,5,3,4] # 其实,使用 l.sort() 之后,就对l进行了排序,然...
@弘兴1273:怎么用python编写好玩的程序 -
延咳18043711608…… 猜数游戏.pyimport random, easygui number = random.randint(1, 99) guess = 0 tries = 0 easygui.msgbox("I have a secret, can you guess?It's a number from 1 to 99. I'll give you 7 tries.") while guess != number and tries < 7: guess = easygui....
@弘兴1273:python的一个简单程序 -
延咳18043711608…… #-*- coding:utf-8 -*- name = raw_input('Please enter your name: ') if name == 'Tom': print 'You are great!' else: print 'You input the wrong name!'
@弘兴1273:写一个简单的PYTHON程序,模拟摇一个色子 -
延咳18043711608…… import random def roll_die_once(min = 1, max = 6): """Roll the die once, with min and max given.""" return random.randrange(min, max+1) def main(): """Accept user input as times, then roll the die repeatedly for times given.""" ...
@弘兴1273:求高手帮写个简单的python程序~~ -
延咳18043711608…… def cal(input="input.txt",output="output.txt"): #cal方法为主程序,推荐这样做而不是PYTHON.EXE xx.py xxx xxx.默认参数为python目录的两个txt,如为其他文件自己指定. infile = file(input,"r")#打开源数据文件 outfile = file(output,"w")#打...
@弘兴1273:python代码 -
延咳18043711608…… #! usr/bin/env python # -*- coding: utf-8 -*- import sys def dispaly(ch) : for i in xrange(0,len(ch)-1) : if ch[i] == chr(127) : print chr(ord(ch[i])-1),'none' elif ch[i] == chr(0) : print 'none',chr(ord(ch[i])+1) else : print chr(ord(ch[i])-1),chr(ord(ch[i])+1) if __...
@弘兴1273:求一个简单的Python程序 在线等 -
延咳18043711608…… import random def roll_die_once(min = 1, max = 6):
@弘兴1273:python 编写简单方程 -
延咳18043711608…… 函数名不能有# 所以: #!python3 import re def extract(s): return [i[1:] for i in re.findall(r'#\w+',s)] print(extract('ABC #123ab! #abc')) print(extract('ABC #123ab! #123ab! #abc'))运行结果: [willie@bogon ~]$ python3 Python 3.5.2 (default, Sep 30 ...
@弘兴1273:python3 写个最简单的程序 -
延咳18043711608…… 用split()分割即可 a = input('input a and b') lista = a.split(',') ans = (int)(lista[0]) + (int)(lista[1]) print(ans)
@弘兴1273:python 可以做哪些有趣的 -
延咳18043711608…… Python 可以做什么,这是一个有趣的问题. 从入门级选手到专业级选手都在做的——爬虫 用 Python 写爬虫的教程网上一抓一大把,据我所知很多初学 Python 的人都是使用它编写爬虫程序.小到抓取一个小黄图网站,大到一个互联网公司的商...