oj2.py-20180414

本文详细介绍了Python中几种常见的输入方法,包括input()函数的基本使用、sys.stdin.readline()用于读取单行输入的特点以及sys.stdin.read()接收多行输入的方式。通过具体示例展示了不同输入方式在实际编程中的应用。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 10 12:10:12 2018

@author: vicky
"""

#input():遇到输入enter停止输入,返回。返回的结果不包含末尾的换行符'\n'
#sys.stdin.read():读取数据 ctrl+d是结束输入 ,enter是换行。故可以接受多行输入
#sys.stdin.readline( ) 只接受一行输入,enter是结束。多行输入要写循环读,循环时ctrl+d是结束 ,enter是换行。

# import sys
# line1 = sys.stdin.readline() #一行输入,enter停止
# line2 = sys.stdin.read() #多行输入,enter换行,ctrl+d停止输入
# for i in range(len(line2)):
#    print(line2[i]+'hello') #输出换行
#    print(line2[i]+'hello',end='') #输出不换行

import sys
line1 = sys.stdin.readline()  #一行输入,enter停止
line2 = sys.stdin.read() #多行输入,enter换行,ctrl+d停止输入
print(len(line1),len(line2))

# #第一题:幸运时刻的个数 (sys用pycharm运行!!!!)
# #输入格式:
# #12:21 34:34
# #输出格式
# #2
# import sys
# #n=sys.stdin.readline().split()
# array = sys.stdin.readline().strip(" ").split()
# sum = 0
# for j in array:
#    if j[0]==j[1] and j[3]==j[4]:
#        sum +=1
#    elif j[0]==j[3] and j[1]==j[4]:
#        sum+=1
#    elif j[0]==j[4] and j[1]==j[3]:
#        sum+=1
# print(sum)

# #a+b
# #输入
# #1 5
# #2 3
# #输出
# #6
# #3
# import sys
# for line in sys.stdin:
#    a = line.split() #以列表的形式读入
#    print(int(a[0])+int(a[1]))
#    #print(a)

# #可输入多行,enter换行,ctrl+d输入结束运行程序
# import sys
# list = []
# list_new = [] #定义一个空列表
# for line in sys.stdin:
# #py.3中input()只能输入一行  sys.stdin按下换行键然后ctrl+d程序结束
#    list_new = line.split()
#    list.extend(list_new)#每一行组成的列表合并
# print(list)

3
1 1 5 10
2 3 4
1 4 6 -5

 

内容概要:本文档是一份关于交换路由配置的学习笔记,系统地介绍了网络设备的远程管理、交换机与路由器的核心配置技术。内容涵盖Telnet、SSH、Console三种远程控制方式的配置方法;详细讲解了VLAN划分原理及Access、Trunk、Hybrid端口的工作机制,以及端口镜像、端口汇聚、端口隔离等交换技术;深入解析了STP、MSTP、RSTP生成树协议的作用与配置步骤;在路由部分,涵盖了IP地址配置、DHCP服务部署(接口池与全局池)、NAT转换(静态与动态)、静态路由、RIP与OSPF动态路由协议的配置,并介绍了策略路由和ACL访问控制列表的应用;最后简要说明了华为防火墙的安全区域划分与基本安全策略配置。; 适合人群:具备一定网络基础知识,从事网络工程、运维或相关技术岗位1-3年的技术人员,以及准备参加HCIA/CCNA等认证考试的学习者。; 使用场景及目标:①掌握企业网络中常见的交换与路由配置技能,提升实际操作能力;②理解VLAN、STP、OSPF、NAT、ACL等核心技术原理并能独立完成中小型网络搭建与调试;③通过命令示例熟悉华为设备CLI配置逻辑,为项目实施和故障排查提供参考。; 阅读建议:此笔记以实用配置为主,建议结合模拟器(如eNSP或Packet Tracer)动手实践每一条命令,对照拓扑理解数据流向,重点关注VLAN间通信、路由选择机制、安全策略控制等关键环节,并注意不同设备型号间的命令差异。
D:\Projects>py -3 -m pip install pandas Collecting pandas Using cached pandas-2.3.1.tar.gz (4.5 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [23 lines of output] + meson setup C:\Users\maying03\AppData\Local\Temp\pip-install-ymoq18oj\pandas_052b7f4652734d1aaf879e7fcd91d151 C:\Users\maying03\AppData\Local\Temp\pip-install-y moq18oj\pandas_052b7f4652734d1aaf879e7fcd91d151\.mesonpy-zb3x0h2x -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --vsenv --native-file=C:\Users\maying03\AppData \Local\Temp\pip-install-ymoq18oj\pandas_052b7f4652734d1aaf879e7fcd91d151\.mesonpy-zb3x0h2x\meson-python-native-file.ini The Meson build system Version: 1.8.3 Source dir: C:\Users\maying03\AppData\Local\Temp\pip-install-ymoq18oj\pandas_052b7f4652734d1aaf879e7fcd91d151 Build dir: C:\Users\maying03\AppData\Local\Temp\pip-install-ymoq18oj\pandas_052b7f4652734d1aaf879e7fcd91d151\.mesonpy-zb3x0h2x Build type: native build Activating VS 16.11.11 Project name: pandas Project version: 2.3.1 C compiler for the host machine: cl (msvc 19.29.30141 "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30141 版") C linker for the host machine: link link 14.29.30141.0 C++ compiler for the host machine: cl (msvc 19.29.30141 "用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.29.30141 版") C++ linker for the host machine: link link 14.29.30141.0 Cython compiler for the host machine: cython (cython 3.1.3) Host machine cpu family: x86_64 Host machine cpu: x86_64 Program python found: YES (D:\Program Files(x86)\Python\python.exe) Need python for x86_64, but found x86 Run-time dependency python found: NO (tried sysconfig) ..\pandas\_libs\tslibs\meson.build:32:7: ERROR: Python dependency not found A full log can be found at C:\Users\maying03\AppData\Local\Temp\pip-install-ymoq18oj\pandas_052b7f4652734d1aaf879e7fcd91d151\.mesonpy-zb3x0h2x\meson-logs\meson-lo g.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
08-15
### 三级标题:解决 pandas 安装过程中 meson 构建依赖失败问题 在使用 32Python 3.12 环境安装 pandas 时,可能会遇到构建失败的问题,尤其是在依赖解析阶段。常见的错误信息包括 `Need python for x86_64 but found x86` 或 `Python dependency not found`,这通常表明构建系统检测到的 Python 架构与当前环境不匹配。此类问题在使用较新的 Python 版本(如 3.12)或特定构建工具(如 Meson)时尤为常见。 当构建系统(如 Meson)尝试解析 Python 依赖时,它会检查 Python 的架构(32 位或 64 位)是否与目标构建架构一致。如果构建系统默认寻找 64 位 Python,而当前环境使用的是 32Python,则会触发 `Need python for x86_64 but found x86` 错误。此外,某些情况下构建系统可能无法正确识别 32Python 的路径或版本,从而导致 `Python dependency not found` 错误。 为解决该问题,可以采取以下措施: 1. **确保使用正确的 Python 架构环境** 在安装 pandas 之前,应确认当前使用的 Python 环境确实是 32 位版本,并且 pip 与该环境绑定。可以通过以下命令检查 Python 架构: ```cmd python -c "import struct; print(struct.calcsize('P') * 8)" ``` 若输出为 `32`,则表示当前为 32 位环境。 2. **使用预编译的 wheel 文件** 由于 pandas 在 PyPI 上提供了针对不同 Python 架构的预编译 wheel 文件,建议优先使用 pip 安装 wheel 版本,而非从源码构建。可使用以下命令安装 pandas: ```cmd pip install pandas ``` pip 会自动选择与当前 Python 架构匹配的 wheel 文件,避免手动干预。 3. **手动指定构建环境参数** 若仍需从源码构建 pandas(例如需要自定义配置),则可在构建前设置环境变量,确保 Meson 正确识别 Python 架构。例如,在 Windows 上可通过设置 `PYTHON` 环境变量指向 32Python 可执行文件: ```cmd set PYTHON=C:\Path\To\Python32\python.exe ``` 然后在构建目录中运行 Meson 配置命令: ```cmd meson setup builddir --prefix=C:\Path\To\Install ``` 确保 `meson.build` 文件中未硬编码要求 64 位 Python 依赖。 4. **更新构建工具链** 某些旧版本的构建工具(如 setuptools、wheel、meson)可能无法正确识别 32Python 3.12 的架构标识,导致依赖解析失败。建议升级至最新版本: ```cmd pip install --upgrade setuptools wheel meson ``` 此举可提升对新版本 Python 和架构的支持兼容性。 5. **避免使用不兼容的依赖库** 若项目中依赖某些仅支持 32Python 的第三方库,需确保这些库的安装路径不会干扰 pandas 的构建过程。可通过虚拟环境隔离不同架构依赖: ```cmd python -m venv env32 env32\Scripts\pip install pandas ``` 该方法可有效避免不同架构库之间的冲突。 ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值