python需要掌握那些语法

1-list数据类型

  1. 内置方法查看长度
  2. len(list)

2.array数据类型

查看形状

3.tuple

取出元组

t = (1, 2, 3, 4, 5)

# 取出第一个元素
2first_element = t[0]
3print(first_element)  # 输出:1
4
5# 取出第三个元素
6third_element = t[2]
7print(third_element)  # 输出:3

self.train_dataset[77]

len( self.train_dataset)
100
self.train_dataset[77]
['p316', array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0.,... 0., 1., 0., 0., 0.],
      dtype=float32), (array([[ 0.2622058 ,  0.2520623 ,  0.22725889, ...,  0.01219749,
         0.01633989,... 0.07434033,  0.07480213]], dtype=float32), array([-1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000...00000e+10, -1.0000000e+10], dtype=float32)), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, ...]
special variables:
function variables:
000: 'p316'
001: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
      dtype=float32)
002: (array([[ 0.2622058 ,  0.2520623 ,  0.22725889, ...,  0.01219749,
         0.01633989,... 0.07434033,  0.07480213]], dtype=float32), array([-1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000...00000e+10, -1.0000000e+10], dtype=float32))
003: None
004: None
005: None
006: None
007: None
008: None
009: None
010: None
011: None
012: None
013: None
014: None
015: None
016: None
017: None
018: None
019: None
020: None
021: None
022: None
023: None
024: None
025: None
026: None
027: None
028: None
029: None
030: None
031: None
032: None
033: None
034: None
035: None
036: None
037: None
038: None
039: None
040: None
041: None
042: None
043: None
044: None
045: None
046: None
047: None
048: None
049: None
050: None
051: None
052: None
053: None
054: None
055: None
056: None
057: None
058: None
059: None
060: None
061: None
062: None
063: None
064: None
065: None
066: None
067: None
068: None
069: None
070: None
071: None
072: None
073: None
074: None
075: None
076: None
077: None
078: None
079: None
080: None
081: None
082: None
083: None
084: None
085: None
086: None
087: None
088: None
089: None
090: None
091: None
092: None
093: None
094: None
095: None
096: None
097: None
098: None
099: None
more: [100:423]
len(): 423

self.train_dataset[0][2]
(array([[ 0.3585394 ,  0.3018739 ,  0.31105113, ...,  0.11300398,
         0.13763978,... 0.19390605,  0.20955321]], dtype=float32), array([-1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000...10,
       -1.0000000e+10], dtype=float32))
special variables:
function variables:
0: array([[ 0.3585394 ,  0.3018739 ,  0.31105113, ...,  0.11300398,
         0.13763978,  0.1481771 ],
       [ 0.39186838,  0.28555837,  0.26440546, ...,  0.05680866,
         0.08005004,  0.08875965],
       [ 0.4017174 ,  0.26269558,  0.2291187 , ...,  0.03097245,
        -0.01500634, -0.05946859],
       ...,
       [ 0.31265986,  0.26113972,  0.24987312, ...,  0.00301073,
        -0.00385549, -0.05521088],
       [ 0.393526  ,  0.3625572 ,  0.2850872 , ...,  0.1024707 ,
         0.10312076,  0.11706395],
       [ 0.4812853 ,  0.4445946 ,  0.38248026, ...,  0.1924281 ,
         0.19390605,  0.20955321]], dtype=float32)
1: array([-1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,  6.4911819e-01,
        6.2345779e-01,  6.4090478e-01,  6.4279598e-01,  6.4552206e-01,
        6.4994138e-01,  6.5974551e-01,  6.6462046e-01,  6.7087328e-01,
        6.6634196e-01,  6.6224831e-01,  6.6087329e-01,  6.5927708e-01,
        6.5056252e-01,  6.3305575e-01,  5.4912585e-01, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,  6.3081306e-01,
        5.2999961e-01,  5.0226504e-01,  4.8222768e-01,  4.5869541e-01,
        4.3690044e-01,  4.3986464e-01,  4.4301969e-01,  4.4689795e-01,
        4.3496856e-01,  4.2702240e-01,  4.1260844e-01,  3.4266099e-01,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,  6.1800110e-01,
        4.4760248e-01,  4.0614852e-01,  3.7573645e-01,  3.6150464e-01,
        3.5052958e-01,  3.3238921e-01,  3.3283028e-01,  3.4399042e-01,
        3.7932014e-01,  3.6280128e-01,  3.4794918e-01,  3.8073543e-01,
        3.9630288e-01,  3.8179722e-01,  3.6594597e-01, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10, -1.0000000e+10, -1.0000000e+10, -1.0000000e+10,
       -1.0000000e+10], dtype=float32)
len(): 2

导入包的路径问题

import sys

sys.path.append('/home/zjx/CosyVoice-main')

在Python中以绝对路径或者相对路径导入文件的方法_使用绝对路径导包-CSDN博客

遍历文件文件夹并进行操作

多线程处理文件的包

python多线程执行同一个函数_mob649e8157ebce的技术博客_51CTO博客

相关推荐
QQ同步助手28 分钟前
如何正确使用人工智能:开启智慧学习与创新之旅
人工智能·学习·百度
流浪的小新36 分钟前
【AI】人工智能、LLM学习资源汇总
人工智能·学习
A懿轩A1 小时前
C/C++ 数据结构与算法【数组】 数组详细解析【日常学习,考研必备】带图+详细代码
c语言·数据结构·c++·学习·考研·算法·数组
南宫生9 小时前
力扣-图论-17【算法学习day.67】
java·学习·算法·leetcode·图论
sanguine__10 小时前
Web APIs学习 (操作DOM BOM)
学习
数据的世界0112 小时前
.NET开发人员学习书籍推荐
学习·.net
四口鲸鱼爱吃盐12 小时前
CVPR2024 | 通过集成渐近正态分布学习实现强可迁移对抗攻击
学习
OopspoO14 小时前
qcow2镜像大小压缩
学习·性能优化
A懿轩A14 小时前
C/C++ 数据结构与算法【栈和队列】 栈+队列详细解析【日常学习,考研必备】带图+详细代码
c语言·数据结构·c++·学习·考研·算法·栈和队列
居居飒15 小时前
Android学习(四)-Kotlin编程语言-for循环
android·学习·kotlin