摘要:
grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 阅读全文
posted @ 2019-03-13 16:28
晨光曦微
阅读(125)
评论(0)
推荐(0)
摘要:
name = ''#名字为空即代表False while not name:#not name=False即 真,将执行循环体 print('Enter your name:') name = input()#给name赋值,如输入了空以外值,不会再有下一个循环while print('How many guests will you have?') numOfG... 阅读全文
posted @ 2019-03-13 16:27
晨光曦微
阅读(366)
评论(0)
推荐(0)
摘要:
#让用户输入一个宠物名字,然后检查该名字是否在宠物列表中 myPets = ['Zophie', 'Pooka', 'Fat-tail'] print('Enter a pet name:') name = input() if name not in myPets: print('I do not have a pet named ' + name) else: print(n... 阅读全文
posted @ 2019-03-13 16:25
晨光曦微
阅读(262)
评论(0)
推荐(0)
摘要:
#! python3 # mapIt.py - Launches a map in the browser using an address from the # command line or clipboard. import webbrowser, sys, pyperclip #如果命令输入了参数,就从命令里得到地名 if len(sys.argv) > 1: # Get add... 阅读全文
posted @ 2019-03-13 16:24
晨光曦微
阅读(384)
评论(0)
推荐(0)
摘要:
import requests,re,json,time from requests.exceptions import RequestException headers={ 'User-Agent':'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' } def get_one_page(url): r=requests.g... 阅读全文
posted @ 2019-03-13 16:23
晨光曦微
阅读(246)
评论(0)
推荐(0)
摘要:
#匹配电话,例如:415-555-4242 def isPhoneNumber(text): if len(text) != 12: return False for i in range(0, 3): if not text[i].isdecimal(): return False if text[3] != '-... 阅读全文
posted @ 2019-03-13 16:21
晨光曦微
阅读(539)
评论(0)
推荐(0)
摘要:
import traceback try: raise Exception('这是一个错误信息') except: errFile=open('err.txt','w') errFile.write(traceback.format_exc()) errFile.close() print('错误信息已经写入err.txt文件中') 阅读全文
posted @ 2019-03-13 16:20
晨光曦微
阅读(254)
评论(0)
推荐(0)
摘要:
import requests,bs4,os #利用 requests 模块下载页面 url='http://xkcd.com' os.makedirs('xkcd', exist_ok=True) #创建一个文件夹xkcd while not url.endswith('#'): res=requests.get(url) res.raise_for_status() #没... 阅读全文
posted @ 2019-03-13 16:19
晨光曦微
阅读(926)
评论(0)
推荐(0)
摘要:
class Dog(): def __init__(self,name,age): self.name=name self.age=age def sit(self): print(self.name.title()+' 现在坐下了') def roll_over(self): print(self.name... 阅读全文
posted @ 2019-03-13 16:18
晨光曦微
阅读(299)
评论(0)
推荐(0)
摘要:
def hello(): print('Howdy!') print('Howdy!!!') print('Hello there.') hello() 阅读全文
posted @ 2019-03-13 16:17
晨光曦微
阅读(230)
评论(0)
推荐(0)

浙公网安备 33010602011771号