Python从入门到精通

一、使用IDEA创建Python项目

文件-新建-项目,语言选择Python,等待python解释器安装成功后即可

二、Python语法基础

python 复制代码
import subprocess

subprocess.run("dir",shell=True,encoding='utf8')
print("hello")
name = "zhangsan"
#name:  zhangsan
print(f"name:  {name}")
#zhangsan
print(name)

name2 = "zhangsann"
#False
print(name == name2)

#从外部输入
high = input("please input high:")
print(f"high: {high}")

#False
print("A" == 65)
print("A"+"1")

#读取外部文件内容
try:
    with open("firsttxt.txt","r",encoding='utf-8') as f:
        content = f.read()
        print(content)
except FileNotFoundError:
    print("file not found")
finally:
    print("try end")

#条件判断
if 8 == 10:
    print(等于)
else:
    print("不等于")

#循环
for i in {1,2,3,4}:
    print(i)
相关推荐
Warson_L11 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅11 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅11 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L11 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅11 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L12 小时前
python的类&继承
python
Warson_L12 小时前
类型标注/type annotation
python
ThreeS14 小时前
手搓MiniVLA全实战教程-一步一步用pytorch解释原理与思路
人工智能·python
金銀銅鐵16 小时前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏