![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
venciliu
这个作者很懒,什么都没留下…
展开
-
笨办法学python笔记:习题14 提示和传递(结合input)
from sys import argv#导入参数模块,import-导入模组(库)script,first,second,third=argv#解包:将每个参数赋予一个变量名print("The script is called:",script)print("Your first variable is:",first)print("Your second variable is:",se原创 2018-02-27 15:21:03 · 470 阅读 · 0 评论 -
笨方法学python笔记:习题7 更多打印
这本书好像还是比较墨迹一点哈哈 例程:print("Marry had a little lamb.")print("It's fleece was white as %s."%'snow')print("And everything that Mary went.")print("."*10)#这在干嘛?重复打印:字符串*数字end1="C"end2="h"end原创 2018-02-24 12:14:30 · 182 阅读 · 0 评论 -
笨方法学python笔记:习题8 打印,打印
formatter="{} {} {} {}"#空格隔开'''str.format()函数:通过{}和:来代替%,用于格式化字符串'''print(formatter.format(1, 2, 3, 4))print(formatter.format("one", "two", "three", "four"))print(formatter.format(True, False, Fa原创 2018-02-25 13:25:30 · 264 阅读 · 0 评论 -
笨办法学python笔记:习题9 打印,打印,打印
# Here's some new strange stuff, remember type it exactly.days="Mon Tue Wed Thu Fri Sat Sun"months="Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"#加上换行print("Here are the days:",days)print("Here are the mon原创 2018-02-25 14:17:08 · 318 阅读 · 1 评论 -
笨办法学python笔记:习题10 那是什么(转义字符)
#字符串中转义字符的使用tabby_cat="\tI'm tabbed in."#制表符persian_cat="I'm splited\non a line."#换行符backslash_cat="I'm \\ a \\ cat"#反斜杠fat_cat="""I'll do a list:\t* Cat food\t* Fishies\t* Catnip\n\t* Grass"""原创 2018-02-25 18:52:10 · 432 阅读 · 0 评论 -
笨办法学python笔记:习题11 提问(input()函数使用)
print("How old are you?",end=' ')#间隔为一个空格,不换行age=input()print("How tall are you?",end=' ')height=input()print("How much do you weight?",end=' ')weight=input()print("So, you're %s old, %s tall a...原创 2018-02-25 19:44:03 · 777 阅读 · 0 评论 -
笨办法学python笔记:习题12 提示别人(pydoc和help使用)
age = input("How old are you? ")height = input("How tall are you? ")weight = input("How much do you weigh? ")#明确了a=input("提示")的用法print("So, you're %s old, %s tall and %s heavy."%(age,height,weight))原创 2018-02-25 23:22:07 · 1018 阅读 · 0 评论 -
爬虫入门-爬取有道在线翻译结果(1)
参考小甲鱼的视频,爬取有道在线翻译结果注意:原视频中的request url地址目前已被反爬虫,不过将地址中的_o删除后就可以实现爬虫(截至2018.4.2),查找网络,貌似是还未封闭的旧接口。import urllib.requestimport urllib.parsecontent=input('请输入需要翻译的内容:')url='http://fanyi.youdao.com/tr...原创 2018-04-02 18:17:14 · 901 阅读 · 1 评论 -
爬虫入门-爬取有道在线翻译结果(2)
由于服务器会识别访问的对象是否为代码并加以限制,所以需要加上一定的措施隐藏代码身份。以上节有道为例:1、添加headers信息:在生成request对象时添加headers信息中的User-Agent属性信息,模仿网页端用户。注意有两种方法,header信息要么在request对象生成前给出,要么在生成之后用add_header()函数添加上去import urllib.requestimpor...原创 2018-04-03 00:49:25 · 1067 阅读 · 0 评论