python learning day19 module

# Yesterday's review: 
# Character group [character]
# Metacharacters:
# \w \d \s
# \W \D \S
# . Any character except newline
# \n \t
# ^ $ matches the beginning of the string And end
# () grouping, is to call the
# re module when the overall quantifier constraint of multiple character groups: grouping has priority
# fiandall
# split
# | Match from left to right, as long as it matches, it will not continue to match, so The long should be put in front
# [^] matches everything except within the character group
# Quantifier
# * 0+
# + 1+
# ? 0-1
# {n} n
# {n,} n+
# {n,m } n+m

# Transfer the problem
# import re
# re.findall(r'\\s')

# Lazy matching
# Add a question mark after the quantifier
# .*?abc Stop as soon as abc is retrieved
# re module
# import re
# re. findall('\d','awir17948jsdc',re.S)
# Return value: all matching items are in the list list

# ret = search('\d(\w)+','awir17948jsdc')
# ret = search('\d(?P<name>\w)+','awir17948jsdc')
# Find the entire string, return if it matches, if not, None
# If there is a return value ret. group() can get the value
# Get the contents of the group: ret.group(1) / ret.group('name')

# match
# Match from the beginning, if it matches, return it, if it doesn't match, it is None
# If Matches the value of .group

# split split
# replace sub and subn
# finditer returns iterator
# compile compile: regular expression is long and needs to be used multiple times

# import re

# ret = re. search("<(?P< tag_name>\w+)>\w+</(?P=tag_name)>","<h1>hello</h1>")
# #You can also use the form of ?<name> to name the group in the group
# # The obtained matching result can be directly used group('name') to get the corresponding value
# print(ret.group('tag_name')) #result: h1
# print(ret.group()) #result: <h1>hello </h1>

# ret = re.search(r"<(\w+)>\w+</\1>","<h1>hello</h1>")
# #If you don't give a name to the group, you can also use \sequential number to find the corresponding group, indicating the content you are looking for and the content of the previous group consistent
# #The matching result obtained can be directly used group (serial number) to get the corresponding value
# print(ret.group(1))
# print(ret.group()) #Result: <h1>hello</h1>

# import re

# ret=re.findall(r"\d+\.\d+|(\d+)","1-2*(60+(-40.35/5)-(-4*3))")
# print( ret) #['1', '2', '60', '40', '35', '5', '4', '3']
# ret.remove('')
​​# print(ret)
# ret=re.findall(r"-?\d+\.\d*|(-?\d+)","1-2*(60+(-40.35/5)-(-4*3))")
# print(ret) #['1', '-2', '60', '', '5', '-4', '3']
# ret.remove("")
# print(ret) # ['1', '-2', '60', '5', '-4', '3']

# 队列
# import queue
# q = queue.Queue()
# q.put([1,2,3])
# q.put(5)
# q.put(6)
# q.put(7)
# print(q)
# print(q.get())
# print(q.get())
# print(q.qsize())
#
# from collections import deque #double-ended queue
# dq = deque([1,2])
# dq.append('a')#put data from the back
#dq.appendleft(' b')#Put data from the front
# print(dq.pop())#Get data from the back
# print(dq.popleft())#Get data from the front
# dq.insert(2,3)#Insert data
# print (dq)

# Ordered Dictionary
# from collections import OrderedDict
# od = OrderedDict([('a',1),('b',2),('c',3)])
# print(od)#this When the dictionary is ordered

# from collections import defaultdict
# d = defaultdict(lambda : 5)
# print(d['k'])

# import time

# formatted time - string: for people to see
# timestamp time ——float time:
# structured time seen by the computer - tuple:

# used for calculation print(time.strftime("%Y/%m/%d %a %H:%M:%S"))# Can be combined arbitrarily
# print(time.strftime("%m/%d %a %H:%M:%S"))
# struct_time=time.localtime()
# print(struct_time)
# print(struct_time.tm_year)

# structured time and timestamp
# t = time.time()
# print(t)
# print(time.localtime(3000000000))
# print(time.gmtime())
# print(time.mktime(time.localtime()))
# print(time.strptime('2000-12-12', "%Y-%m-%d"))
# print(time.asctime())#Almighty Player

#Random Module
#Refer to the teacher's blog
import os
# print (os.getcwd())
# os.chdir(r'C:\Users\Administrator\PycharmProjects')
# print(os.getcwd())

# os.chdir('..')
# print(os.getcwd( ))
# os.makedirs('dirname1/dirname2')
# os.removedirs('dirname1/dirname2')

# os.mkdir('dirname1/dirname')

# print(os.listdir(r'C:/Users/Administrator/PycharmProjects/s9'))

# print(os.stat('1.复习.py'))

# print(os.sep) # python代码跨平台 :linux windows
# /user/bin/

# os.system("dir")
# ret = os.popen("dir").read()
# print(ret)

# print(os.environ)

# print(os.getcwd())
# print(os.path.split(os.getcwd()))

# print(os.path.join(r'C:\Users\Administrator','user','local'))
# print(os.getcwd())
# print(os.path.getsize(os.path.join(os.getcwd(),'1.复习.py')))

import sys
# print(sys.platform)
# print(sys.version)


# print(sys.path.clear())


# ret = sys.argv # pwd = ret [2]
# name = ret [1]

# if name == 'alex' and pwd == 'alex3714':
# print('Login successful')
# else:
# print("Wrong username and password")
# sys.exit()
# print('You can used calculator')