Python Basics-day32__python

Source: Internet
Author: User
Import re
ret=re.findall (r "\d+", "1-2* (60+ ( -40.35/5)-( -4*3))")
print (ret)
Ret=re.findall (R "\d+\.\d+|" ( \d+) "," 1-2* (60+ ( -40.35/5)-( -4*3)) ")      #对于浮点数, you can match, but because of the existence of the group, it displays the '
ret.remove (')
print (ret)
# Sometimes unwanted content needs to be matched.
# because you don't want something that contains what you want
#这个道理, for the following reptiles,
#获取你需要的信息,
#通过周围信息的特点, locate where you need information,




#一个爬虫的小例子, import re from urllib.request import urlopen def getpage (URL): #参数为网址 re Sponse = Urlopen (URL) #打开网址, return Response.read (). Decode (' Utf-8 ') #获取网址的代码, the default is bytes shape , so we need to encode the Utf-8 def parsepage (s): com = Re.compile (#对我们需要爬取信息的特点, describe, and get the information in a grouped way , ' <div class= ' item ' >.*?<div class= ' pic ' >.*?<em .*?> (? p<id>\d+). *?<span class= "title" > (? P<title>.*?) </span> '. *?<span class= "Rating_num" .*?> (? P<rating_num>.*?) </span>.*?<span> (? P<comment_num>.*?) Evaluation </span> ', re. s) ret = Com.finditer (s) for i in RET: # yield I yield {#我们这里 is a generator, "id": I.group ("id"), "title": I.group ("title"), "Rating_num": I.group ("Rating_
Num ")," Comment_num ": I.group (" Comment_num "),} def main (num):    url = ' https://movie.douban.com/top250?start=%s&filter= '% num response_html = getpage (URL) ret = Parsepag E (response_html) print (ret) #打印结果: <generator object parsepage at 0x000001fd417288e
        0> f = open ("Move_info7", "W", encoding= "UTF8") for obj in Ret:print (obj) data = str (obj) F.write (data + "\ n") f.close () if __name__ = = ' __main__ ': Count = 0 for I in range (2): Main (count #网站默认一页显示25条记录, the value here affects the beginning of the first few, Count + #比如1-25 and 3 -27 of the difference,




# b/S
# Unified The entrance of all applications

# Mobile End why B/s not fire, because the display effect has yet to be improved,

# C/S architecture contains almost all the network development architecture Form
# B/S framework is also C/s structure, why so say? You can understand this, the browser is a special client, that is, b/s architecture of the clients are browser browser


# Django Tornado flask B/S Architecture software Development



# 8-bit 2, know why the byte is 8 bits? Because at first, 8-bit is just enough to express English symbols, numbers and special symbols, which is probably why we need to do encode coding at the top?
# The IP address represents which small network you have in the entire network, and the MAC address helps you determine which device you have in this small network,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.