#!/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. 硬件协议之i2c

    https://blog.csdn.net/ctyqy2015301200079/article/details/83830326  (此文章可能有误) 从目前来看,所有读写操作(包括ACK的读写)都 ...

  2. 安装redhat6.10 出现的问题

    安装redhat6.10 操作系统不定时重启情况说明   曾出现报错如下: 在UEFI模式下安装RHEL6.10,安装完毕后系统第一次重启无法进入操作系统,同时屏幕上出现错误提示: Invalid m ...

  3. 分布式共识算法随笔 —— 从 Quorum 到 Paxos

    分布式共识算法随笔 -- 从 Quorum 到 Paxos 本文主要参考各类英文文献,部分专业术语翻译较为生硬,望谅解. 概览: 为什么需要共识算法? 昨夜西风凋碧树,独上高楼,望尽天涯路 复制(Re ...

  4. JZOJ 3234. 阴阳

    阴阳 题面 分析 个人认为是极好的题,很容易写 如果你学点分治是无奈背板的,那就做做这道题,加深你对点分治的理解 一般的,处理树上大规模统计问题,我们分治的关键是找一棵子树的重心 找到分治中心,即新一 ...

  5. CRT 与 exCRT

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

  6. 代码随想录算法训练营day20 | leetcode ● 654.最大二叉树 ● 617.合并二叉树 ● 700.二叉搜索树中的搜索 ● 98.验证二叉搜索树

    LeetCode 654.最大二叉树 分析1.0 if(start == end) return节点索引 locateMaxNode(arr,start,end) new root = 最大索引对应节 ...

  7. Android:LitePal 在第一次创建表之后第二次创建新的表不生效

    因为业务需求的增长,后续需要继续创建新的表,有可能代码没有任何报错,同时数据库也没有任何新的表加入进来. 修改 litepal.xml 的 version,如果之前是 1,那么修改为 2,总之比之前 ...

  8. 基于IGServer的Web地图要素空间分析

    1. 引言 MapGIS IGServer 是中地数码的一款跨平台GIS 服务器产品,提供了空间数据管理.分析.可视化及共享服务 MapGIS IGServer的下载(试用)地址:MapGIS IGS ...

  9. PostgreSQL的10进制与16进制互转

    1.10进制转16进制Postgres里面有一个内置的10进制转16进制的函数:to_hex(int)/to_hex(bigint) [postgres@localhost ~]$ psql Pass ...

  10. pycharm 关闭符号自动补全

    insert pair bracket 是三种括号的自动补全 insert pair quote 是两种引号的自动补全