查看变量内存地址   id(变量名)

ni = 123

n2 = 123

ni和n2肯定是用的两份内存,但是python对于数字在-5~257之间的数字共用一份地址,范围可以修改

name = ‘李璐’

for i in name:

  print(i)   //将会打印出李璐

  print(bytes(i,encoding='utf-8'))   //把utf-8编码的字符转换成字节流

--恢复内容开始---

  1. name1 = "wupeiqi"
  2. name2 = name1

---恢复内容结束---

pycharm工具使用ctrl + /  可以批量注释

1、查看对象的类,或对象所具备的功能

  temp = ‘ssss’

  dir(temp)  可以字符串类所有该功能

  help(temp) 或者help(type(temp))可以详细接受每种功能

class str(basestring):
"""
str(object='') -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
"""
def capitalize(self):
""" 首字母变大写 """

def center(self, width, fillchar=None):
""" 内容居中,width:总长度;fillchar:空白处填充内容,默认无 """

def count(self, sub, start=None, end=None):
""" 子序列个数 """

def decode(self, encoding=None, errors=None):
""" 解码 """

def encode(self, encoding=None, errors=None):
""" 编码,针对unicode """

def endswith(self, suffix, start=None, end=None):
""" 是否以 xxx 结束 """

def expandtabs(self, tabsize=None):
""" 将tab转换成空格,默认一个tab转换成8个空格 """
     ‘hello\t999’ -> ‘hello 999’

def find(self, sub, start=None, end=None):
""" 寻找子序列位置,如果没找到,返回 -1 """

def format(*args, **kwargs): # known special case of str.format
""" 字符串格式化,动态参数,将函数式编程时细说 """
     'hello {0},age {1}'.format('alex',19) -> hello alex,age 19

def index(self, sub, start=None, end=None):
""" 子序列位置,如果没找到,报错 """

def isalnum(self):
""" 是否是字母和数字 """

def isalpha(self):
""" 是否是字母 """

def isdigit(self):
""" 是否是数字 """

def islower(self):
""" 是否小写 """

def isspace(self):
    是否是空格

def istitle(self):
    是否是标题(单词首字母是不是都大写)

def isupper(self):
    是否大写

def join(self, iterable):
""" 连接 """
b是列表或者元组 a.join(b) -> 把列表 b中每个元素用a连接起来

def ljust(self, width, fillchar=None):
""" 内容左对齐,右侧填充 """

def lower(self):
""" 变小写 """

def lstrip(self, chars=None):
""" 移除左侧空白 """

def partition(self, sep):
""" 分割,前,中,后三部分 """
"""
S.partition(sep) -> (head, sep, tail)(元组)

def replace(self, old, new, count=None):
""" 替换 """
"""count表示从左往右替换多少个
S.replace(old, new[, count]) -> string

def rfind(self, sub, start=None, end=None):
"""从右往左找
S.rfind(sub [,start [,end]]) -> int

def rindex(self, sub, start=None, end=None):
"""

def rjust(self, width, fillchar=None):
"""
S.rjust(width[, fillchar]) -> string

Return S right-justified in a string of length width. Padding is
done using the specified fill character (default is a space)
"""
return ""

def rpartition(self, sep):
"""
S.rpartition(sep) -> (head, sep, tail)

def rsplit(self, sep=None, maxsplit=None):
"""
S.rsplit([sep [,maxsplit]]) -> list of strings
从左边开始分割

def rstrip(self, chars=None):
"""把右边空白移除
S.rstrip([chars]) -> string or unicode

def split(self, sep=None, maxsplit=None):
""" 分割, maxsplit最多分割几次 """
"""
S.split([sep [,maxsplit]]) -> list of strings

def splitlines(self, keepends=False):
""" 根据换行分割 """
"""
S.splitlines(keepends=False) -> list of strings

def startswith(self, prefix, start=None, end=None):
""" 是否已摸个字符或者字符串起始 """
"""
S.startswith(prefix[, start[, end]]) -> bool

def strip(self, chars=None):
""" 移除两段空白 """
"""
S.strip([chars]) -> string or unicode

def swapcase(self):
""" 大写变小写,小写变大写 """

def title(self):
"""
字符串”变成标题

“the sheool” -> 'The School'

def translate(self, table, deletechars=None):
"""
转换,需要先做一个对应表,最后一个表示删除字符集合
intab = "aeiou"
outtab = "12345"
trantab = maketrans(intab, outtab)
str = "this is string example....wow!!!"
print str.translate(trantab, 'xm')
"""

def upper(self):
"""
S.upper() -> string

Return a copy of the string S converted to uppercase.
"""
return ""

def zfill(self, width):
"""方法返回指定长度的字符串,原字符串右对齐,前面填充0。"""
"""
S.zfill(width) -> string

Pad a numeric string S with zeros on the left, to fill a field
of the specified width. The string S is never truncated.
"""
return ""

def _formatter_field_name_split(self, *args, **kwargs): # real signature unknown
pass

def _formatter_parser(self, *args, **kwargs): # real signature unknown
pass

def __add__(self, y):
""" x.__add__(y) <==> x+y """
pass

def __contains__(self, y):
""" x.__contains__(y) <==> y in x """
pass

def __eq__(self, y):
""" x.__eq__(y) <==> x==y """
pass

def __format__(self, format_spec):
"""
S.__format__(format_spec) -> string

Return a formatted version of S as described by format_spec.
"""
return ""

def __getattribute__(self, name):
""" x.__getattribute__('name') <==> x.name """
pass

def __getitem__(self, y):
""" x.__getitem__(y) <==> x[y] """
pass

def __getnewargs__(self, *args, **kwargs): # real signature unknown
pass

def __getslice__(self, i, j):
"""
x.__getslice__(i, j) <==> x[i:j]

Use of negative indices is not supported.
"""
pass

def __ge__(self, y):
""" x.__ge__(y) <==> x>=y """
pass

def __gt__(self, y):
""" x.__gt__(y) <==> x>y """
pass

def __hash__(self):
""" x.__hash__() <==> hash(x) """
pass

def __init__(self, string=''): # known special case of str.__init__
"""
str(object='') -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.
# (copied from class doc)
"""
pass

def __len__(self):
""" x.__len__() <==> len(x) """
pass

def __le__(self, y):
""" x.__le__(y) <==> x<=y """
pass

def __lt__(self, y):
""" x.__lt__(y) <==> x<y """
pass

def __mod__(self, y):
""" x.__mod__(y) <==> x%y """
pass

def __mul__(self, n):
""" x.__mul__(n) <==> x*n """
pass

@staticmethod # known case of __new__
def __new__(S, *more):
""" T.__new__(S, ...) -> a new object with type S, a subtype of T """
pass

def __ne__(self, y):
""" x.__ne__(y) <==> x!=y """
pass

def __repr__(self):
""" x.__repr__() <==> repr(x) """
pass

def __rmod__(self, y):
""" x.__rmod__(y) <==> y%x """
pass

def __rmul__(self, n):
""" x.__rmul__(n) <==> n*x """
pass

def __sizeof__(self):
""" S.__sizeof__() -> size of S in memory, in bytes """
pass

def __str__(self):
""" x.__str__() <==> str(x) """
pass

  1.  

4、python基本知识点及字符串常用方法的更多相关文章

  1. 【python基础语法】字符串常用方法 、列表(第3天课堂笔记)

    """ 字符串的方法 join 字符串拼接,将列表转换为字符串 find 查找元素位置 count 查找元素个数 replace 替换字符 split 字符串分割,将字符 ...

  2. python 整型、字符串常用方法、for循环

    整型--int 定义:用于比较和计算 python2和python3: python2:python2中油int(整型)和long(长整型):1231312L+ 进制转换: 十进制转二进制:正除2,获 ...

  3. python学习之字符串常用方法和格式化字符串

    Python中的字符串同样适用标准的序列操作(索引,分片,乘法,成员判断,求长度,取最小值和最大值),但因为字符串是不可变的,因此字符串不支持分片赋值. s='http://www.baidu.com ...

  4. python基础(2)字符串常用方法

    python字符串常用方法 find(sub[, start[, end]]) 在索引start和end之间查找字符串sub ​找到,则返回最左端的索引值,未找到,则返回-1 ​start和end都可 ...

  5. python 字符串常用方法

    字符串常用方法 capitalize() String.capitalize() 将字符串首字母变为大写 name = 'xiaoming' new_name = name.capitalize() ...

  6. python基础3 字符串常用方法

    一. 基础数据类型 总览 int:用于计算,计数,运算等. 1,2,3,100...... str:'这些内容[]'    用户少量数据的存储,便于操作. bool: True, False,两种状态 ...

  7. Python基础二_操作字符串常用方法、字典、文件读取

    一.字符串常用方法: name.captitalize()                       #字符串首字母大写 name.center(50,'*')                   ...

  8. python浅谈正则的常用方法

    python浅谈正则的常用方法覆盖范围70%以上 上一次很多朋友写文字屏蔽说到要用正则表达,其实不是我不想用(我正则用得不是很多,看过我之前爬虫的都知道,我直接用BeautifulSoup的网页标签去 ...

  9. .Net程序员之Python基础教程学习----字符串的使用 [Second Day]

         在The FirstDay 里面学习了列表的元组的使用,今天开始学习字符串的使用.字符串的使用主要要掌握,字符串的格式化(C语言中我们应该都知道,Python和C语言差别不大),字符串的基本 ...

随机推荐

  1. RQNOJ PID496/[IOI1999]花店橱窗布置

    PID496 / [IOI1999]花店橱窗布置 ☆   题目描述 某花店现有F束花,每一束花的品种都不一样,同时至少有同样数量的花瓶,被按顺序摆成一行,花瓶的位置是固定的,从左到右按1到V顺序 编号 ...

  2. 洛谷 P2117 小Z的矩阵

    P2117 小Z的矩阵 题目描述 小Z最近迷上了矩阵,他定义了一个对于一种特殊矩阵的特征函数G.对于N*N的矩阵A,A的所有元素均为0或1,则G(A)等于所有A[i][j]*A[j][i]的和对2取余 ...

  3. (七十一)关于UITableView退出崩溃的问题和滚动究竟部的方法

    [TableView退出崩溃的问题] 近期在使用TableView时偶然发如今TableView中数据较多时,假设在滚动过程中退出TableView到上一界面.会引起程序的崩溃.经过网上查阅和思考我发 ...

  4. UIWebView 无缝切换到 WKWebView

    WKWebView 是IOS8新增的 Web浏览视图 长处:   载入速度  比UIWebView提升差点儿相同一倍的, 内存使用上面,反而还少了一半. 缺点:   WKWebView 不支持缓存 和 ...

  5. Codeforces Beta Round #2 C. Commentator problem

    模拟退火果然是一个非常高端的东西,思路神马的全然搞不懂啊~ 题目大意: 给出三个圆,求一点到这三个圆的两切线的夹角相等. 解题思路: 对于这个题来说还是有多种思路的 .只是都搞不明确~~   /害羞脸 ...

  6. 在JAVA中怎样跳出当前的多重嵌套循环?

    在JAVA中怎样跳出当前的多重嵌套循环?         这道题是考察大家对于break语句的应用.同一时候也是对你多重嵌套循环的使用进行考察.在java中,要想跳出多重循环,能够在外循环语句前面定义 ...

  7. 61.C++文件操作实现硬盘检索

    #include <iostream> #include <fstream> #include <memory> #include <cstdlib> ...

  8. Linux / Windows应用方案不完全对照表

    Linux/Windows应用方案不完全对照表 650) this.width=650;" border="0" src="http://img1.51cto. ...

  9. OpenCV —— ROI

    通过 cvResetImageRoI 函数释放ROI是非常重要的,否则其他操作将默认在ROI区域中进行 通过巧妙的使用widthStep,可以达到同ROI一样的效果 —— 如果想设置和保持一副图像的多 ...

  10. jq--图片懒加载

    html 1.给图片不给真真意义上的src属性路径,可通过我们自己想要添加时改变它的属性路径即可. 2.要获取浏览器中三种高度. $(window).height();//屏幕高度 $(window) ...