1. int 类型转换

a = "123"
b = int(a)
b = b+10
print(type(a),a)
print(type(b),b)

2. int(num,base=2), base不写的时候默认为10

a = "0011"
b = int(a,base=2)
print(b)

  答案为 3.

3. -.bit_length() 当前数字为2进制时,至少要用多少位来表示

a = 8
b = a.bit_length()
print(b)

 answer:4

4. str 居住 center()

a = "kkkk"
b = a.center(20,"&")
print(b)
#"&"中只能填一个 &&&&&&&&kkkk&&&&&&&&

5. str 之count()计数

count(self, sub, start=None, end=None)
a = "kkkkrrrrrrrrrxxxxxxxxx"
b = a.count('r',5,14)
print(b) 8

6. find(self, sub, start=0, end=_sys.maxsize) 比index()好用

a = "djalskfjs;kd k"
b = a.find("ja",0,20)
print(b) 1

7. format(self, *args, **kwargs ) 两种方式效果一样

a = 'jkldak{ff},ioeu{gg}'
b = a.format(ff='JOAN',gg='HUMAN')
print(b) a = 'jkldak{0},ioeu{1}'
b = a.format('JOAN','HUMAN')
print(b) jkldakJOAN,ioeuHUMAN

8. format_map(self, mapping)

format_map(self, mapping): # real signature unknown; restored from __doc__

9. def isalnum(self, *args, **kwargs): # real signature unknown

  Return True if the string is an alpha-numeric string, False otherwise.
												

python int str的更多相关文章

  1. 【python】python各种类型转换-int,str,char,float,ord,hex,oct等

    [python] int(x [,base ])         将x转换为一个整数 long(x [,base ])        将x转换为一个长整数 float(x )             ...

  2. python基础-2 编码转换 pycharm 配置 运算符 基本数据类型int str list tupple dict for循环 enumerate序列方法 range和xrange

    1.编码转换 unicode 可以编译成 UTF-U GBK 即 #!/usr/bin/env python # -*- coding:utf-8 -*- a = '测试字符' #默认是utf-8 a ...

  3. Python学习笔记之基础篇(三)python 数据类型 int str bool 详谈

     python 的数据类型: 1.int:存放 1,2,3 等数据 ,用于数字的运算 2.bool :True, False 用于判断 3.str:字符串,用来存储少量的数据 4.list : 数组的 ...

  4. 嵌入式 python之str操作

    1.字符串的对齐方式:①:center(int[,str])>>> string = 'Fishhat'>>> string.center(55)'         ...

  5. python int异常 python isdigit

    python int是python把任何类型转换成int类型的方法,但是你如果运用不好的话,会引发异常,但是python的str字符串转换方法运用起来倒是比较安全,它把任何对象转换成字符串类型都不会报 ...

  6. 基础数据类型(int,str,bool)

    一 python 中的基础数据类型 1.int  数字类型(整数类型)  主要用来数学计算 2.str  字符串   可以保存少量数据进行操作 3.bool  布尔值  判断真假   True  Fa ...

  7. Python - int()

    参考 https://docs.python.org/3/library/functions.html?highlight=int#int If x is not a number or if bas ...

  8. Python之str()与repr()的区别

    Python之str()与repr()的区别 str()一般是将数值转成字符串,主要面向用户.  repr()是将一个对象转成字符串显示,注意只是显示用,有些对象转成字符串没有直接的意思.如list, ...

  9. python的str,unicode对象的encode和decode方法

    python的str,unicode对象的encode和decode方法 python中的str对象其实就是"8-bit string" ,字节字符串,本质上类似java中的byt ...

随机推荐

  1. P3628 [APIO2010]特别行动队(斜率优化dp)

    P3628 [APIO2010]特别行动队 设$s[i]$为战斗力前缀和 显然我们可以列出方程 $f[i]=f[j]+a*(s[i]-s[j])^{2}+b*(s[i]-s[j])+c$ $f[i]= ...

  2. Greeting Card

    问题 G: Greeting Card 时间限制: 1 Sec  内存限制: 128 MB 提交: 666  解决: 59 [提交] [状态] [命题人:admin] 题目描述 Quido plans ...

  3. 论文笔记:Structure Inference Net: Object Detection Using Scene-Level Context and Instance-Level Relationships

    Structure Inference Net: Object Detection Using Scene-Level Context and Instance-Level Relationships ...

  4. 【HNOI 2018】道路

    Problem Description \(W\) 国的交通呈一棵树的形状.\(W\) 国一共有\(n - 1\)个城市和\(n\)个乡村,其中城市从\(1\)到\(n - 1\) 编号,乡村从\(1 ...

  5. 洛谷 P2915 【[USACO08NOV]奶牛混合起来Mixed Up Cows】

    类似于n皇后的思想,只要把dfs表示放置情况的数字压缩成一个整数,就能实现记忆化搜索了. 一些有关集合的操作: {i}在集合S内:S&(1<<i)==1: 将{i}加入集合S:S= ...

  6. Vue:(四)Ajax(Vue-Resource)

    Vue 要实现异步加载需要使用到 vue-resource 库.(挂载到vue实例上) (一)Vue-Resource引入 <script src="https://cdn.stati ...

  7. C/C++.【转】解析URL的转义字符百分比(%)字符串

    1.来自:[HTTP]_[C_C++]_[解析URL的转义字符百分比字符串] - 猪一戒 - 博客园.html(http://www.cnblogs.com/zhuyijie/p/6465303.ht ...

  8. pagex/y offsetx/y screenx/y clientx/y 用法及区别

    1  pagex/pagey:鼠标相对于整个页面的x/y坐标 注:整个页面的意思就是你整个页面的全部 例如:宽200px 高400px 那么pagex/y他们最大值就是它 2,offsetX/y与pa ...

  9. iOS10 后 http 网页定位失效解决方案

    最近公司开发一个app项目H5+ MUI框架进行开发的,开发的相关人员离职后,我这个小菜鸟...都是泪(从未接触过app开发) 项目要嵌入百度地图,由于已经做了微信版本的,想着还是用js api 做吧 ...

  10. Java ceil() 方法

    语法: double ceil(double d) double ceil(float f) 参数 double 或 float 的原生数据类型. 返回值 返回 double 类型,返回值大于或等于给 ...