names = ['李明博', '咖喱棒']
person = {'name':'咖喱棒', 'age':18}
nums = (1,2,3,4,)
object = { 9,'李明博',True}
print(type(names))
name = '李明博'
age = 15
print('姓名:%s,年龄:%s' %(name,age))
message = '''
你好:%s
世界:%d
'''% (name,age)
print(message)
message = '{}{}岁了'.format(name,age)
print(message)
print( '{}{}岁了'.format(name,age))
print(9/2,9//2)
print('abc' == 'abc')
age2 = 15
print(age is age2)
print(True and False,True or False,not True)
print(3 & 2)
print(3 | 2)
print(~5)
print(3^5)
print(2 >> 1)
print(2 << 2)
a = 6
b = 5
print((a + b) if a > b else (a - b))
print((a + b) if a < b else (a - b))
if 1:
print('True')
if 0:
print('False')
else:
print('True')
if ():
pass
elif ():
pass
else:
pass
import random
print(random.randint(8,9))
for i in range(3):
print("123")
for i in range(1,2):
print("2")
for name in names:
print(name)
for i in range(1,10,3):
print(i)
print(list(range(1,10,3)))
if 1:
pass
for i in range(1,10):
if i == 1:
print("3")
break
while i<3:
print(i)
i+=1
print('李明' in name)
print(name[1])
print(name[0:2])
print(name[1:])
str = 'abcde'
print(str[0:-3])
print(str[-1:])
print(str[:-1])
print(str[::-1])
print('abcde'.upper())
print('ABCDE'.lower())
print(str.find('d'))
print(str.find('a',1,3))
print(str.find('a',1))
url = 'https://www.bilibili.com/video/BV1R7411F7JV?p=44'
print(url.rfind('/'))
print(str.replace('a','b',1))
print(name.encode('utf-8'))
print('abc.txt'.endswith('txt'))
print('abc.txt'.startswith('abc'))
print('abc'.isalpha())
print('123'.isdigit())
print('-'.join('abc'))
print(' hello world'.lstrip())
print(' hello '.rstrip())
print('a b c d'.split(' '))
print('a b c d'.split(' ',2))
print('abbcccdddd'.count('c'))
numbers = ['1','2','3','4','5']
for i in range(len(numbers)):
if numbers[i] == '3':
numbers[i] = '8'
l = len(numbers)
i = 0
while i < l:
if '4' in numbers[i]:
del numbers[i]
l-=1
continue
i += 1
print(numbers)
numbers.remove('1')
print(numbers)
names.append('水男')
print(names)
heronames = ['钢铁侠']
print(heronames + names)
names.insert(2,'蜘蛛甲')
print(names)
print(max(numbers))
print(min(numbers))
dignum = [2,1,4,3,5,6,7,8,9,10]
print(sum(dignum))
print(sorted(dignum))
dignum.sort()
print(dignum)
print(sorted(dignum,reverse=True))
dignum.sort(reverse=False)
print(dignum)
dignum.reverse()
print(dignum)
print(names * 3)
print([3,2] in list)
print(list[1][0])
nums = [1,2,3,4,5,6]
print([num for num in nums if num > 3])
print([i for i in range(1,100) if i%3 == 0 and i%5 == 0])
print([(x,y) for x in range(5) if x%2==0 for y in range(5) if y%2==0])
score = [{'name':'张三','garde':80},{'name':'李四','garde':85},{'name':'王五','garde':90}]
print([data['garde']+1 if data['garde']<90 else data['garde']-2 for data in score])
g = (x*3 for x in range(5))
while True:
try:
print(next(g))
except:
print('到达调用次数上限')
break
def func():
n = 0
while True:
n+=1
yield n
g = func()
print(next(g))
def funb():
i = 0
while i<5:
temp = yield i
print(temp)
i+=1
g = funb()
print(g.send(None))
print(g.send('你好'))
print(g.send('你好a'))
strabc = 'abc'
print(list(strabc))
print(set(strabc))
print(tuple(strabc))
print(dignum.pop())
print(type(3))
print(tuple(dignum))
print(nums.index(3))
nums = (1, 2, 3, 4)
a,b,c,d = nums
print(a,b,c,d)
a,*_ = nums
print(a,_)
print(*(4, 8, 6))
print(list(nums))
dict1 = dict([('name','李明博'),('age','18')])
print(dict1)
print(dict1.items())
dict1['power'] = '100'
print(dict1)
dict1['name'] = '咖喱棒'
print(dict1)
i = 0
database = []
while i < 2:
user = {}
if( i == 0 ):
user['name'] = '水男'
user['age'] = '18'
else:
user['name'] = '冰男'
user['age'] = '17'
i+=1
database.append(user)
print(database)
dict2 = {}
dict2['张三'] = 98
dict2['李四'] = 95
dict2['王五'] = 90
for key,value in dict2.items():
if value > 90:
print(key)
print(dict2.keys())
print(dict2.values())
print('张三' in dict2)
print(dict2.get('张三'))
print(dict2.get('赵云',96))
print(dict2['张三'])
dict2.pop('张三')
print(dict2.pop('赵云',50))
print(dict2)
dict2.popitem()
print(dict2)
dict2.clear()
print(dict2)
dict3 = {1:'张三',2:'李四',3:'王五'}
dict4 = {1:'赵云',4:'马超'}
dict3.update(dict4)
print(dict3)
print(list(dict3))
list2 = [1,2,2,3,3,3,4,4,4,4]
print(set(list2))
set1 = {1,2,3,4,5}
set1.add(6)
print(set1)
tuple1 = (7,8)
set1.update(tuple1)
print(set1)
set1.update({9,10})
print(set1)
set1.remove(10)
print(set1)
set1.discard(10)
print(set1)
set1.pop()
print(set1)
print(set1)
set2 = {2,3}
print(set1 - set2)
print(set1.difference(set2))
print(set1 & set2)
print(set1.intersection(set2))
print(set1 | set2)
print(set1.union(set2))
print(set1 ^ set2)
print(list(set1))
itname = ''
if itname:
print('存在')
else:
print('不存在')
```python
if __name__ == '__main__':
pass
import sys
print(sys.path)
print(sys.version)
import time
print(time.time())
print(time.ctime(time.time()))
print(time.localtime(time.time()))
print(time.localtime(time.time()).tm_hour)
print(time.mktime(time.localtime(time.time())))
print(time.strftime('%Y-%m-%d'))
import datetime
print(datetime.date.ctime(datetime.date(2020,8,20)))
print(datetime.datetime.now())
timedel = datetime.timedelta(hours=2,days=5)
print(datetime.datetime.now() + timedel)
import random
print(random.random())
print(random.randrange(1,10))
print(random.randrange(1,10,2))
print(random.randint(1,10))
list1 = ['张三','李四','王五']
print(random.choice(list1))
random.shuffle(list1)
print(list1)
print(chr(65))
print(ord('A'))
import hashlib
print(hashlib.md5('你好啊'.encode('utf-8')).hexdigest())
import requests
import re
s = '大帅哥是我'
print(re.match('我',s))
print(re.search('我',s))
print(re.search('我',s).span())
print(re.search('我',s).group())
username = 'admin001'
print(re.match('[a-zA-Z][0-9a-zA-Z]{5,}$',username))
print(re.search('^[a-zA-Z][0-9a-zA-Z]{5,}$',username))
msg = 'aa.py bb.py cc.py apy.txt'
print(re.findall(r'py\b',msg))
print(re.findall(r'\w*\.py\b',msg))
n = '39'
print(re.match('[1-9]?\d',n))
print(re.match('[1-9]?\d$|100$',n))
email = '1104815607@qq.com'
print(re.match(r'\w{5,20}@(126|163|qq)\.com$',email))
msg = '<html><h1>abc</h1></html>'
print(re.match(r'<(?P<name1>\w+)><(?P<name2>\w+)>(.+)</(?P=name2)></(?P=name1)>',msg).group())
print(re.match(r'<([0-9a-z-A-Z]+)><([0-9a-z-A-Z]+)>(.+)</\2></\1>$',msg))
print(re.sub(r'\d+','90','java:100,python:99'))
print(re.split(r'[:,]','java:100,python:99'))
num = '0570-3099758'
print(re.match(r'(\d{3}|\d{4})-(\d{7})',num).group(1))
msg = 'abc123abc'
print(re.match(r'abc(\d+)',msg))
print(re.match(r'abc(\d+?)',msg))