This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
num = randint(1,1000) | |
print 'Guess what i think?' | |
bingo = False | |
while bingo == False: | |
answer = input() | |
if answer < num: | |
print '%d is too small.' % answer | |
if answer > num: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isEqual(num1,num2): | |
if num1 < num2: | |
print '%d is too small.' %num1 | |
return False | |
if num1 > num2: | |
print '%d is too big.' %num1 | |
return False | |
if num1 == num2: | |
print 'BINGO,you win!!!' | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(numbers=None): | |
if numbers is None: | |
numbers = [] | |
numbers.append(9) | |
print numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding:utf-8 | |
''' | |
@author:Byron | |
新浪微博:http://weibo.com/ziyuetk | |
''' | |
import urllib2, json | |
from city import city | |
yourcity = raw_input("你想查那个城市的天气?") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
city = { | |
'北京': '101010100', | |
'海淀': '101010200', | |
'朝阳': '101010300', | |
'顺义': '101010400', | |
'怀柔': '101010500', | |
'通州': '101010600', | |
'昌平': '101010700', | |
'延庆': '101010800', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!usr/bin/python | |
#coding:utf-8 | |
''' | |
@author:Byron | |
新浪围脖:http://weibo.com/ziyuetk | |
''' | |
import urllib2 | |
from bs4 import BeautifulSoup | |
print "豆瓣正在热映:" | |
url = "http://movie.douban.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding:utf-8 | |
#作者:Byron | |
#博客:http://jiabin.tk | |
import urllib2 | |
import re | |
#定义程序主函数 | |
def qiubai(page): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding:utf-8 | |
#author:byron | |
#blog:http://jiabin.tk | |
import random | |
def m_n(): | |
print("本程序会从1~n中随机取m个数,1<=m<=n") | |
n = int(input("输入n的值:")) | |
m = int(input("输入m的值:")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "aAsmr3idd4bgs7Dlsf9eAF" | |
#只保留数字 | |
list(filter(str.isdigit, text)) | |
#只保留字母 | |
list(filter(str.isalpha, text)) | |
def f(x):return x%2 != 0 and x%3 != 0 | |
list(filter(f,range(1,50))) | |
#结果:[1, 5, 7, 11, 13, 17, 19, 23, 25, 29, 31, 35, 37, 41, 43, 47, 49] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"sig":"622d7ee0ecfb76f037511f3d7f64bf23ae46466551ad99f9124dce8b80ce2207d04b7dd8af9c5f50d24a9fa4bc6b20580af275bfb30359e93fc6f9f37ae272ed1","msghash":"ae1e2bb7c5704d063ad39d3fe0e0411d8ba55eb40ca6c18901d29c7cafdba9dd"} |