#!/usr/bin/python
# -*- coding: UTF-8 -*-
from lib_001_decorator_log_funcname import decorator_log_funcname 
s1 = 'hello s1'
s2 = "hello s2"
s3 = '''
guyu
  conghua
    123
'''
@decorator_log_funcname
def _test_define():
#    print("\n_test_define")
    print(s1)
    print(s2)
    print(s3)   
@decorator_log_funcname
def _test_string_plus_string():
#    print("\n_test_string_plus_string")
    ss = s1 + " " + s2
    print(ss)
@decorator_log_funcname
def _test_string_cut():
#    print("\n_test_string_cut")
    ss = s1[0:3]
    print(ss)  
    ss = s1[2:4]
    print(ss)       
def _test_string_length():
    print("\n_test_string_length")  
    print(s1.__len__())    
    print(s3.__len__()) 
def _test_string_pos( ss, i ):
    print("\n_test_string_pos")  
    print(ss.find(i))
def _test_string_replace( ss, sub1, sub2 ):
    print("\n_test_string_replace") 
    ss.replace( sub1, sub2 )
    print(ss)
    print(s1) 
    ss = ss.replace( sub1, sub2 )
    print(ss)
    print(s1)     
def _func_string_insert( ss, pos, sub1 ):
    print("\n_func_string_insert") 
    l = list(ss)
    l.insert(pos, sub1)
    ss = ''.join(l)
    print(ss)
def _func_string_del( ss, sub1 ):
    print("\n_test_string_del") 
    ss = ss.replace( sub1, "" ) 
    print(ss)  
def _func_get_last_n_char( ss, n ):
    print("\n_func_get_last_n_char")    
    ll = ss.__len__()
    print( ss[ ll-n : ll ] )     
def _test():
    _test_define()
    _test_string_plus_string()
    _test_string_cut()
    _test_string_length()
    _test_string_pos(s1, 'llo')
    _test_string_replace(s1, 's1', 'xx')
    _func_get_last_n_char(s1, 2)
    _func_string_insert(s1, 1, 'xx')
    _func_string_del(s1,"el")
    
if __name__ == '__main__':
    _test()

python_test_0001_base_string的更多相关文章

随机推荐

  1. UEFI引导安装UBUNUT

    1.引导方式一定要选UEFI,否则一些显卡驱动将不能安装 2.安装的时候,要在第四个界面,也就是选择覆盖安装还是保留双系统的那个界面,选择其他,一定要自己分区 3.分区: 4.一共5个重要分区: 1. ...

  2. SRE:如何提高报警有效性?

    为什么要提升<报警有效性> 过多的报警会让负责人麻木 过多的报警会增加短信和电话的成本 提升根因定位效率 如何定义<报警有效性> 不漏报 不误报 不重报 不延报 如何量化 MT ...

  3. 有趣的python库-pillow

    pillow-图像处理 安装时不再是PIL,是pillow哦! 烟花 pillow + tkinter实现 import tkinter as tk from PIL import Image, Im ...

  4. BI工具术语表大全:从字母A-Z全面收录

    谈到商业智能行业,变革是不可避免的.为了跟上步伐,各种各样的BI 解决方案正在快速迭代更新,以满足企业的数字化需求,那么市场上BI 工具种类繁杂,到底如何选择适合功能全面.满足自己企业运转情况的.合适 ...

  5. CRT 与 exCRT

    感觉网上很多写的都不是很清楚啊 awa. CRT 就是解这个方程 \(\begin{cases}x\equiv r_1 \pmod {m_1}\\ x\equiv r_2 \pmod {m_2} \\ ...

  6. SpringMVC基础源码分析(一)

    实现Controller的三种方式分析 每种实现的方式对应的HanderAdapter都不同. 实现Controller接口 该接口对应的HanderAdapter为SimpleControllerH ...

  7. struct device_node *

    struct device_node *test_node; test_node->name name出不来 struct device_node *test_device_node; test ...

  8. vscode cmake工程launch和task文件设置

    1.launch.json文件基本设置 { // Use IntelliSense to learn about possible attributes. // Hover to view descr ...

  9. [后端-Flask总结]-flask学习总结

    1.flask开发基础与入门: 1.1web开发基础 1.1.1 前端框架: bootstrap, j-query, angular, react 1.2 flask 路由 from flask im ...

  10. Neo4j安装及简单使用【转】

    转载防丢失. 一.Neo4j和图数据库简介 neo4j是基于Java语言编写图形数据库.图是一组节点和连接这些节点的关系.图形数据库也被称为图形数据库管理系统或GDBMS. Neo4j的是一种流行的图 ...