提交 21b5fdec 编写于 作者: 秦英杰

fix:基础语法

上级 d63485fe
<component name="InspectionProjectProfileManager"> <component name="InspectionProjectProfileManager">
<profile version="1.0"> <profile version="1.0">
<option name="myName" value="Project Default" /> <option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true"> <inspection_tool class="DotEnvLowercaseKeyInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="DotEnvSpaceAroundSeparatorInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="DotEnvSpaceInsideNonQuotedInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="DuplicatedCode" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
<inspection_tool class="HtmlFormInputWithoutLabel" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
<option name="myValues">
<value>
<list size="3">
<item index="0" class="java.lang.String" itemvalue="lay-verify" />
<item index="1" class="java.lang.String" itemvalue="lay-submit" />
<item index="2" class="java.lang.String" itemvalue="lay-filter" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
<inspection_tool class="JSUnusedAssignment" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyArgumentListInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyBroadExceptionInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyDictCreationInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyExceptionInheritInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyInterpreterInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyMethodMayBeStaticInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignoredPackages">
<value>
<list size="5">
<item index="0" class="java.lang.String" itemvalue="chromadb" />
<item index="1" class="java.lang.String" itemvalue="openai" />
<item index="2" class="java.lang.String" itemvalue="fastapi" />
<item index="3" class="java.lang.String" itemvalue="chromadb-client" />
<item index="4" class="java.lang.String" itemvalue="langchain" />
</list>
</value>
</option>
</inspection_tool>
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="E501" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false">
<option name="ignoredErrors"> <option name="ignoredErrors">
<list> <list>
<option value="N802" /> <option value="N802" />
<option value="N803" />
<option value="N806" />
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true"> <inspection_tool class="PyProtectedMemberInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyShadowingNamesInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyStatementEffectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyTestUnpassedFixtureInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyTypeCheckerInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyTypedDictInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyUnreachableCodeInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="false" level="WARNING" enabled_by_default="false">
<option name="ignoredIdentifiers"> <option name="ignoredIdentifiers">
<list> <list>
<option value="socketio.*" /> <option value="socketio.*" />
</list> </list>
</option> </option>
</inspection_tool> </inspection_tool>
<inspection_tool class="PyprojectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ShellCheck" enabled="true" level="ERROR" enabled_by_default="true">
<shellcheck_settings value="SC2006,SC2164,SC2181" />
</inspection_tool>
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
<inspection_tool class="SqlConstantConditionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SqlConstantExpressionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SqlDialectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="UnsatisfiedRequirementInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="VulnerableLibrariesLocal" enabled="false" level="WARNING" enabled_by_default="false" />
</profile> </profile>
</component> </component>
\ No newline at end of file
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
<component name="MaterialThemeProjectNewConfig"> <component name="MaterialThemeProjectNewConfig">
<option name="metadata"> <option name="metadata">
<MTProjectMetadataState> <MTProjectMetadataState>
<option name="userId" value="e706d3a:190c6184f70:-7c34" /> <option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="1961fa40:1886d73b1f5:-8000" />
<option name="version" value="8.13.2" />
</MTProjectMetadataState> </MTProjectMetadataState>
</option> </option>
</component> </component>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (chatgpt)" project-jdk-type="Python SDK" /> <component name="Black">
<option name="sdkName" value="Python 3.9 (chatgpt)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="web" project-jdk-type="Python SDK" />
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/python-demo.iml" filepath="$PROJECT_DIR$/.idea/python-demo.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module version="4"> <module version="4">
<component name="NewModuleRootManager">
<orderEntry type="jdk" jdkName="Python 3.9 (chatgpt)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings"> <component name="PyDocumentationSettings">
<option name="format" value="PLAIN" /> <option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" /> <option name="myDocStringFormat" value="Plain" />
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
此差异已折叠。
name = """ name = """
多行注释 多行注释
""" """
"""
WEFSFSDFWF
"""
print(name) print(name)
# 写一个整数字面量 # 写一个整数字面量
666 666
# 写一个浮点数字面量 # 写一个浮点数字面量
13.14 13.14
# 222
# 写一个字符串字面量 # 写一个字符串字面量
"程序员" "程序员"
...@@ -14,7 +19,6 @@ print(name) ...@@ -14,7 +19,6 @@ print(name)
print(666) print(666)
print(13.14) print(13.14)
print("程序员") print("程序员")
# 单行注释 # 单行注释
# #
# #
......
# 方式1: 使用print直接输出类型信息 # 方式1: 使用print直接输出类型信息
print(type("程序员")) print(type("程序员"))
print(type(666)) int_type = type(666)
print(int_type)
print(type(11.345)) print(type(11.345))
# 方式2: 使用变量存储type()语句的结果 # 方式2: 使用变量存储type()语句的结果
string_type = type("程序员") string_type = type("程序员")
int_type = type(666) int_type = int_type
float_type = type(11.345) float_type = type(11.345)
print(string_type) print(string_type)
print(int_type) print(int_type)
print(float_type) print(float_type)
# 方式3: 使用type()语句,查看变量中存储的数据类型信息 # 方式3: 使用type()语句,查看变量中存储的数据类型信息
name = "程序员" name = "程序员"
name_type = type(name) name_type = type(name)
......
...@@ -21,3 +21,5 @@ print("数字11宽度限制5,结果是:%5d" % num1) ...@@ -21,3 +21,5 @@ print("数字11宽度限制5,结果是:%5d" % num1)
print("数字11宽度限制1,结果是:%1d" % num1) print("数字11宽度限制1,结果是:%1d" % num1)
print("数字11.345宽度限制7,小数精度2,结果是:%7.2f" % num2) print("数字11.345宽度限制7,小数精度2,结果是:%7.2f" % num2)
print("数字11.345不限制,小数精度2,结果是:%.2f" % num2) print("数字11.345不限制,小数精度2,结果是:%.2f" % num2)
print(f"message = {name},成立于:{setup_year},我今天的股价是:{stock_price}")
\ No newline at end of file
...@@ -4,9 +4,16 @@ ...@@ -4,9 +4,16 @@
""" """
# 定义变量存储布尔类型的数据 # 定义变量存储布尔类型的数据
bool_1 = True bool_1 = True
#
# if today == 21:
# bool_1 = False
print(f"bool_1={bool_1}")
bool_2 = False bool_2 = False
print(f"bool_1变量的内容是:{bool_1}, 类型是:{type(bool_1)}") print(f"bool_1变量的内容是:{bool_1}, 类型是:{type(bool_1)}")
print(f"bool_2变量的内容是:{bool_2}, 类型是:{type(bool_2)}") print(f"bool_2变量的内容是:{bool_2}, 类型是:{type(bool_2)}")
# 比较运算符的使用 # 比较运算符的使用
# == , !=, >, <, >=, <= # == , !=, >, <, >=, <=
# 演示进行内容的相等比较 # 演示进行内容的相等比较
......
...@@ -12,6 +12,3 @@ elif int(input("请告诉我今天几号:")) == 1: ...@@ -12,6 +12,3 @@ elif int(input("请告诉我今天几号:")) == 1:
print("今天是1号免费日,可以免费") print("今天是1号免费日,可以免费")
else: else:
print("不好意思,条件都不满足,需要买票10元。") print("不好意思,条件都不满足,需要买票10元。")
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
""" """
sum = 0 sum = 0
i = 1 i = 1
res = []
while i <= 100: while i <= 100:
sum += i sum += i
print(i) print(i)
res.append(i)
i += 1 i += 1
print(f"1-100累加的和是:{sum}") print(f"1-100累加的和是:{str(res)}")
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
演示for循环的练习题:数一数有几个a 演示for循环的练习题:数一数有几个a
""" """
# 统计如下字符串中,有多少个字母a # 统计如下字符串中,有多少个字母a
name = "itheima is a brand of itcast" # name = "itheima is a brand of itcast"
name = [1, 2, 3, 4, 5]
# 定义一个变量,用来统计有多少个a # 定义一个变量,用来统计有多少个a
count = 0 count = 0
# for 循环统计 # for 循环统计
# for 临时变量 in 被统计的数据: # for 临时变量 in 被统计的数据:
for x in name: for x in name:
if x == "a": if x == 3:
count += 1 count += 1
print(f"被统计的字符串中有{count}个a") print(f"被统计的字符串中有{count}个a")
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
""" """
name = "itheima" name = "itheima"
# range
for x in name: for x in name:
if x == "i":
print(x)
# 将name的内容,挨个取出赋予x临时变量 # 将name的内容,挨个取出赋予x临时变量
# 就可以在循环体内对x进行处理 # 就可以在循环体内对x进行处理
print(x) print(x)
......
...@@ -12,9 +12,11 @@ ...@@ -12,9 +12,11 @@
# print(x) # print(x)
# range 语法3 range(num1, num2, step) # range 语法3 range(num1, num2, step)
# for x in range(5, 10, 2): for x in range(5, 10, 3):
# # 从5开始,到10结束(不包含10本身)的一个数字序列,数字之间的间隔是2 # 从5开始,到10结束(不包含10本身)的一个数字序列,数字之间的间隔是2
# print(x) print(x)
for x in range(10): # for x in range(5):
print("送玫瑰花") # print(x)
# if x % 2 == 0:
# print("送玫瑰花")
...@@ -10,14 +10,14 @@ num = random.randint(1, 10) ...@@ -10,14 +10,14 @@ num = random.randint(1, 10)
# continue # continue
# print("语句2") # print("语句2")
# 演示continue的嵌套应用 # 演示continue的嵌套应用
# for i in range(1, 6): for i in range(1, 6):
# print("语句1") print("语句1")
# for j in range(1, 6): for j in range(1, 6):
# print("语句2") print("语句2")
# continue continue
# print("语句3") print("语句3")
#
# print("语句4") print("语句4")
# 演示循环中断语句 break # 演示循环中断语句 break
# for i in range(1, 101): # for i in range(1, 101):
# print("语句1") # print("语句1")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册