目录
前言
一、环境搭建
二、数学运算、字符串和文本、列表
1.数学运算
2.字符串与文本
3.列表
前言
太久不写Python了,最近工作用到才发现语法基本已经忘得差不多,所以从基础语法开始重新回顾一下,并将重点内容梳理出来,感谢datawhale平台提供的优质学习资源,参考链接:DATAWHALE - 一个热爱学习的社区
一、环境搭建
使用Pycharm进行学习
二、数学运算、字符串和文本、列表
1.数学运算
print("I will now count my chickens:")
print("Hens", 25 + 30 / 6)
输出:
I will now count my chickens:
Hens 30.0
2.字符串与文本
print("I will now count my chickens:")
print("Hens", 25 + 30 / 6)
输出:
I will now count my chickens:
Hens 30.0
2.字符串与文本
字符引用的两种方法:
cars = 100
print("There are", cars, "cars available")
输出:
# There are 100 cars available
my_name = '小丹炉'
print(f"Let's talk about {my_name}.") # f前缀表示在字符串内支持大括号内的表达式
输出:
# Let's talk about 小丹炉.
字符串引用也可以嵌套:
types_of_people = 10
x = f"There are {types_of_people} types of people."
y = f"I said: '{x}'." # 注意单引号
print(y)
输出:
# I said: 'There are 10 types of people.'
可以用 + 连接两个字符串
w = "This is the left side of..." e = "a string with a right side." print(w+e) 输出: # This is the left side of...a string with a right side.



