1. for 循环遍历列表每个元素
students_list = ['lilei', 'hanmeimei', 'madongmei']
for student in students_list:
print(student)
# output
lilei
hanmeimei
madongmei
原创...大约 1 分钟
The site is used to record what I have seen and learned in my lifetime, including but not limited to computers, artificial intelligence, mathematics, pop culture, travel, photography, music, aesthetic accumulation etc.
students_list = ['lilei', 'hanmeimei', 'madongmei']
for student in students_list:
print(student)
# output
lilei
hanmeimei
madongmei
while not user_answer_correct:
user_gender = input('请输入您的性别(F/M):')
if user_gender == 'F':
print('您是女生')
user_answer_correct = True
elif user_gender == 'M':
print('你是男生')
user_answer_correct = True
else:
print('wrong')
在 python 中相同位置的代码表示他们是同一个代码块
用四个空格或者一个 Tab 来表示缩进(切忌混用!)
condition = True
while condition:
a = 1
if a < 10:
print(f'a>>>{a}')
意义:表示判断中的是与否。一般用于条件测试中。
In [1]: a = True
In [2]: a
Out[2]: True
In [3]: 10 < 5
Out[3]: False
In [4]: 10 > 8
Out[4]: True
我们有以下联系人:
姓名 | 手机号 |
---|---|
李雷 | 123456 |
韩梅梅 | 132456 |
大卫 | 154389 |
Mr.Liu | 131452 |
Bornforthis | 180595 |
Alexa | 131559 |
引言: 这篇文章旨在为 Ryan 本人服务
# 右对齐
a = 123
print('{0:_>4}'.format(a)) # _123
b = 1111
print('{0:&>10}'.format(b)) # &&&&&&1111
# 左对齐
a = 'a'
print('{0:*<5}'.format(a)) # a****
# 居中
a = 'middle'
print('{0:#^16}'.format(a)) # #####middle#####
print('{0:#^15}'.format(a)) # ####middle#####
print('{0:#^17}'.format(a)) # #####middle######
# 导入sympy 中所有内容
from sympy import *