文章目录
安装python环境
有解释器:
设置环境:
熟悉Python
python
var1 = 1 # 整型
var2 = 1.1 # 浮点型
var3 = 1 + 2j # 复数
var4 = 'hello' # 字符串
var5 = True # 布尔型
var6 = [1, 2, 3] # 列表List
var7 = (1, 2, 3) # 元组Tuple
var8 = {1, 2, 3} # 集合Set
var9 = {'name': 'Tom', 'age': 18} # 字典Dict
# use
print(var9['name'])
# 嵌套
var9 = {'name': 'Tom', 'age': [1, 2, 3]} # 字典Dict
print(var9)
def print_hi(name):
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
return "nihao"
def sum_num(a, b):
return a + b
print(print_hi('PyCharm'))
print(sum_num(1, 2))
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def print_info(self):
print(f'Name: {self.name}, Age: {self.age}')
xiaoming = Person('小明', 18)
xiaoming.print_info()
安装torch
安装:
python
pip3 install torch torchvision