GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python_test/test5.py at master · Hanlen520/python_test

Expand file tree

/

test5.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
22 lines (17 loc) · 599 Bytes
/

test5.py

Copy path

File metadata and controls

22 lines (17 loc) · 599 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 练习列表生成式,这个很好用,越用越爽
l = [x for x in range(10)]
print(l)
# 还可以加条件来筛选元素,这里筛选偶数
l = [x for x in range(10) if x % 2 == 0]
print(l)
# 对两个列表生成一个也可以,生成全排列
l = [x + y for x in 'XYZ' for y in 'abc']
print(l)
# 也可以生成字典
d = {x:y for x in 'xyz' for y in 'ABC'}
print(d)
# 作业:将列表的字符串的大写改成小写,不是字符串的就去掉
L1 = ['Hello', 'World', 18, 'Apple', None]
print(L1)
L2 = [s.lower() for s in L1 if isinstance(s,str)]
print(L2)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.