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博客

相关推荐
阿超爱嵌入式5 分钟前
STM32学习笔记之RCC模块(实操篇)
笔记·stm32·学习
yanyu-yaya6 分钟前
devextreme-react/scheduler 简单学习
前端·学习·react.js
淬渊阁13 分钟前
汇编学习之《运算和逻辑指令》
汇编·学习
别来无恙20214 分钟前
算法设计学习4
c++·学习
小王努力学编程22 分钟前
动态规划学习——回文子串系列问题【C++】
c++·学习·算法·leetcode·动态规划
Cynthia的梦1 小时前
Linux学习-Linux进程间通信(IPC)聊天程序实践指南
linux·运维·学习
代码AC不AC1 小时前
【数据结构】队列
c语言·数据结构·学习·队列·深度讲解
生信小鹏2 小时前
Nature旗下 | npj Digital Medicine | 图像+转录组+临床变量三合一,多模态AI预测化疗反应,值得复现学习的完整框架
人工智能·学习·免疫治疗·scrna-seq·scrna
云上艺旅2 小时前
K8S学习之基础六十九:Rancher创建svc资源
学习·云原生·容器·kubernetes·rancher
陌言不会python3 小时前
谷粒微服务高级篇学习笔记整理---thymeleaf
笔记·学习·微服务