zoukankan      html  css  js  c++  java
  • 14、python基础

    一 标准数据类型
    1 整形和浮点形
    python2.*与python3.*关于整型的区别
    python2.*
    在32位机器上,整数的位数为32位,取值范围为-2**31~2**31-1,即-2147483648~2147483647

    在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-9223372036854775808~9223372036854775807
    python3.*整形长度无限制
    查看方式:
    整形:   print(type(n))
    浮点形:  print(type(f))
     2 特点
       a.只能存放一个值
       b.一经定义,不可更改
       c.直接访问
    例:x=10
         print(id(x))
           x=11
          print(id(11))
    3字符串类型
    s=‘hello Word’ 
     
    二 字符串常用操作
    1 去掉空格:
    命令输入用户名:  name=input(‘username:   ’)
         去掉空格          name.strip()
    2 首字母大写
       x=‘hello’
       print(x.capitalize())
    3 所有字母大写
       x=‘hello’
       print(x.upper())
    4 居中显示
       x.‘hello’
       print(x.center(30,‘#’))
    5 统计某个字符的长度  空格也算字符
       x='hello love'
    print(x.count(l))      找到l位置
    print(x.count(‘1’,0,4))   #0 1 2 3 
    6 以()结尾
       x=‘hello’
       print(x.endswith())
    7 以()开头
       print(x.startswith())
    8 找相应索引的值
       x=‘hello’
       print(x.find())
    9 格式化字符串,和写入内容
       msg=‘Name:{},age:{},sex:{}’
       print(msg.format())
     10 查看某个字符的索引
       x=‘hello word’
       print(x.index() )
    11 显示处  判断结果为真
       x=‘123’
       print(x.isdigit())
    12 替换
       msg=‘hello alex’
       print(msg.replace(‘x’,‘X’))
    13 分割
       print(x.split())
  • 相关阅读:
    HTML5的智能提示在VisualStudio2010
    浏览器的缓存机制
    等待资源(wait_resource)解码(完整版)
    对quartz的总结
    利用Spring动态对Quartz定时任务管理
    Tomcat源码分析(一)服务启动
    深入分析 Java 中的中文编码问题
    企业搜索引擎开发之连接器connector(一)
    SpringQuartz (一)
    Quartz 项目应用笔记
  • 原文地址:https://www.cnblogs.com/f1443526266/p/6959647.html
Copyright © 2011-2022 走看看