#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
from lib_001_decorator_log_funcname import decorator_log_funcname
d1 = 10 + 2
s1 = "456"
@decorator_log_funcname
def _test_int_to_string():
    ss = str(d1)
    print("is ss a string:", isinstance(ss, str))
    print(ss.__len__(), ss)
@decorator_log_funcname
def _test_string_to_int():
    dd = int(s1)
    print("is dd a int:", isinstance(dd, int))    
    print(dd+1)    
@decorator_log_funcname
def _test_time_to_string():
    tt = time.time()            #  type(tt) -> <class 'float'>
    tt = time.localtime()       #  type(tt) -> <class 'time.struct_time'>
    xx = time.asctime(tt)
    print("type xx",type(xx))
    print(xx)
    ss = time.strftime("%Y/%m/%d, %H:%M:%S",tt) #  type(ss) -> <class 'str'>
    print(type(ss))
    print(ss)
@decorator_log_funcname
def _test_string_to_time():
    ss = "2022/10/2"
    tt = time.strptime(ss, "%Y/%m/%d")
    print(type(tt))
    print(tt)
    ff = time.mktime(tt)
    print("type ff", type(ff))
    print(ff)
@decorator_log_funcname
def _test_list_to_string():
    ll = []
    ll.append('guyu')
    ll.append('123')
    ll.append('conghua')
    ss = ''.join(ll)
    print(ss)
@decorator_log_funcname
def _test_string_to_list():
    ss = 'guyu'
    ll = []
    ll = list(ss)
    print(ll)
    ll = []
    ss = "guyu conghua yingying"
    ll = ss.split(" ")
    print(ll)
@decorator_log_funcname
def _test_utf8_to_string():
    utf8 = b'guyu1234\xe5\x8f\xa4\xe5\xae\x87'
    ss = utf8.decode('utf-8')
    print(type(ss))
    print(ss)
@decorator_log_funcname
def _test_string_to_utf8():
    ss = "guyu1234古宇"
    utf8 = ss.encode("utf-8")
    print(utf8)
def _test():
    _test_int_to_string()
    _test_string_to_int()
    _test_time_to_string()
    _test_string_to_time()
    _test_list_to_string()
    _test_string_to_list()
    _test_utf8_to_string()
    _test_string_to_utf8()    
    
if __name__ == '__main__':
    _test()

python_test_0001_base_string_swap的更多相关文章

随机推荐

  1. 微信小程序【关于地址信息的接入以及自动选择当前位置】

    在做收货地址的时候,通常会让用户填写或者打开地图选择收获地址,此时就需要用到微信提供的地址API,在使用地址API的时候需要注册对应的API,而且地址API会经常调整,需要关注官方公告,下面就是关于地 ...

  2. 加密,各种加密,耙梳加密算法(Encryption)种类以及开发场景中的运用(Python3.10)

    不用说火爆一时,全网热议的Web3.0区块链技术,也不必说诸如微信支付.支付宝支付等人们几乎每天都要使用的线上支付业务,单是一个简简单单的注册/登录功能,也和加密技术脱不了干系,本次我们耙梳各种经典的 ...

  3. LOJ.数列分块入门3

    题目 分析 由大题目知此题分块 注意处理前驱下标的合法性 \(Code\) #include<cstdio> #include<cmath> #include<algor ...

  4. Java开发中要避免的坑和一些代码优化技巧

    1:动态SQL遇到的坑,先看下面OGNL表达式的说明. Any object can be used where a boolean is required. OGNL interprets obje ...

  5. vue2和vue3区别

    1. vue2和vue3双向数据绑定原理发生了改变 vue2的双向数据绑定是利用了es5 的一个API Object.definepropert() 对数据进行劫持 结合发布订阅模式来实现的.vue3 ...

  6. PostGIS之空间连接

    1. 概述 PostGIS 是PostgreSQL数据库一个空间数据库扩展,它添加了对地理对象的支持,允许在 SQL 中运行空间查询 PostGIS官网:About PostGIS | PostGIS ...

  7. MATH026th: 《矩斋筹算丛刻》

    矩斋筹算丛刻 (清)劳乃宣辑 清光绪刻朱墨套印本 2函22册竹纸线装 提要:内含 <古筹算考释>.<古筹算考释续编>.<筹算浅释>.<筹算分法浅释>.& ...

  8. node.js 中删除,修改等接口

    1.首先是引入模块.闯将服务器,设置路由等 二.查询员工接口 三.添加员工接口 四.删除员工接口 五.修改员工接口

  9. EF Core自动将实体映射到数据库

    protected override void OnModelCreating(ModelBuilder modelBuilder) { try { var compilationLibrary = ...

  10. Windows常用快捷键(但我本人不太熟知的)

    Shift+Ctrl+ESC: 打开任务管理器 Windows+E: 打开文件资源管理器 Windows+R: 运行文件 Windows+Tab: 切换应用程序 Shift+Delete: 永久删除