# -*- coding: utf-8 -*-
print('123', 123)
print(type('123'), type(123)) # string, integer /ˈintidʒə/
print('123' + str(1), 123 + 1)
print('123' + str(1), 123 + int('1')) def binary_add(x, y):
carry = 0 # 进位。把溢出的携带到高位。
i = len(x) - 1
z = []
while i >= 0:
t = x[i] + y[i] + carry
if t >= 2:
carry = 1
t -= 2
else:
carry = 0
z.insert(0, t)
i -= 1
print(x, ' +\n', y, ' =\n', z, sep='') binary_add( [0, 0, 1, 0], (0, 0, 1, 1) ) # A tuple is a read-only list # n进制的数相加,某位最大n-1 + n-1 = 2n - 2,n-2留着,高位+1相当于低位+n,如9+9=1*10+8。更正: 忘了低位进来的1了。
# canonical(以最简数学方式)不是cannon(大炮)的形容词,后者两个n。
# 能搞明白纠错码的人不多,会补码就行。2 - 3 = 2 + (-3) = 010 + (~011 + 001) = 010 + 101 = 111
# -3 + 3 = 0 => -3 + 011 = 000 => ? 按位求反得到“互补”的两个数(像两把梳子错个齿),它们的和是111, 再加1=0
# flip-flop: 人字拖鞋走起来啪嗒啪嗒:触发器 = trigger (扳机、触发、触发器) print(len('\n'), '"' + '\n' + '"')
print(len('\\n'), '"' + '\\n' + '"') # CR: carriage return, 字车返回(左边); LF: line feed,喂一行(纸往上卷一行); 都是机械打字机(typewriter)的术语。New line: 新行
# type+writer, type: printed letters, 印刷出的字母。typeface: 字体=font
# cast: 铸造, typecast: 重铸类型/类型转换,如int('123')
# 如果整不明白if A and (not B or C),就整多条if,每条只整ABC中的一个,起码加print方便
# 写顺了a += b; a *= c, 别忘了a != 1不是a = !1 # eval(expression), exec(statement)
exec('gate_1_a = 0')
exec('gate_1_b = 1')
exec('gate_1_c = gate_1_a or gate_1_b')
exec('gate_2_a = gate_1_c')
exec('gate_2_b = not gate_2_a')
print(gate_2_b)
# exec(source, globals=None, locals=None, /)
# Execute the given source in the context of globals and locals.
# The source may be a string representing one or more Python statements or a code object as returned by compile().
# The globals must be a dictionary and locals can be any mapping, defaulting to the current globals and locals.
# If only globals is given, locals defaults to it.
str = '''
def wierd_func(a, b):
if a > b:
return b + 1
else:
return a + 1
'''
print(str)
exec(str)
exec('x = wierd_func(2, 3)')
print(x) str = '''
# CSDN python getter setter
class Latch:
def __init__(this): this.x = 0
def set_(this, x): this.x = x
def get_(self): return self.x
def reset(): this.x = 0
'''
print(str)
exec(str)
exec('l1 = Latch()')
#exec('l1.set_(1)')
print(l1.get_()) quit()
with open(file_name, 'r', encoding='utf-8') as f:
for line in f:
words = line.split()
kw = words[0].lower()
for word in words:
if len(word) > 13: print(word)
dic[word.lower()] = kw

最新文章

  1. 浅析inline-block--使用inline-block创建布局
  2. Hopcroft-Karp模板学习小结
  3. JOIN 相关内容
  4. 【百度地图API】JS版本的常见问题
  5. 关于git fetch 和git pull 的区别
  6. Hadoop, Python, and NoSQL lead the pack for big data jobs
  7. 汉字转拼音(pinyin4j-2.5.0.jar)
  8. Guava 15新特性介绍
  9. [转]Go语言(golang)开源项目大全
  10. Python3基础 lambda表达式 简单示例
  11. Slave_SQL_Runing:NO 复制出现问题的解决办法
  12. 不能直接获取?聊聊如何在Shader Graph中获取深度图
  13. [python]目录及文件操作
  14. spring cloud config git库文件搜索顺序
  15. 数模转换ADC08009应用
  16. Vue 组件&组件之间的通信 之 template模板引用与动态组件的使用
  17. 使用jquery+css实现瀑布流布局
  18. BZOJ4034[HAOI2015]树上操作——树链剖分+线段树
  19. Openstack CentOS6.5 ALL IN ONE 安装
  20. CPU profiling

热门文章

  1. linux下创建文件的文件权限问题
  2. 【java设计模式】(10)---模版方法模式(案例解析)
  3. Tcpdump 常用命令、参数记录
  4. docker 简单总结
  5. Eclipse 中的Maven常见报错及解决方法
  6. selenium截屏操作(也支持截长图)
  7. [linux]centos7.4部署django+Uwsgi+Nginx
  8. [啃书] 第1篇 - 输入输出/变量类型/math函数
  9. Python基础(__slots__)
  10. Ubuntu軟件商店加載失敗的解決方法