# -*- 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

add more的更多相关文章

  1. AutoMapper:Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type

    异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 应用场景:ViewModel==>Mode映射的时候出错 AutoMappe ...

  2. EntityFramework Core 1.1 Add、Attach、Update、Remove方法如何高效使用详解

    前言 我比较喜欢安静,大概和我喜欢研究和琢磨技术原因相关吧,刚好到了元旦节,这几天可以好好学习下EF Core,同时在项目当中用到EF Core,借此机会给予比较深入的理解,这里我们只讲解和EF 6. ...

  3. ASP.NET Core: You must add a reference to assembly mscorlib, version=4.0.0.0

    ASP.NET Core 引用外部程序包的时候,有时会出现下面的错误: The type 'Object' is defined in an assembly that is not referenc ...

  4. [转]NopCommerce How to add a menu item into the administration area from a plugin

    本文转自:http://docs.nopcommerce.com/display/nc/How+to+code+my+own+shipping+rate+computation+method Go t ...

  5. [deviceone开发]-动态添加组件add方法的示例

    一.简介 这个示例详细介绍ALayout的add方法的使用(原理也适用于Linearlayout),以及add上去的新ui和已有的ui如何数据交换,初学者推荐.二.效果图 三.相关下载 https:/ ...

  6. [LeetCode] Add Two Numbers II 两个数字相加之二

    You are given two linked lists representing two non-negative numbers. The most significant digit com ...

  7. [LeetCode] Add Strings 字符串相加

    Given two non-negative numbers num1 and num2 represented as string, return the sum of num1 and num2. ...

  8. [LeetCode] Expression Add Operators 表达式增加操作符

    Given a string that contains only digits 0-9 and a target value, return all possibilities to add ope ...

  9. [LeetCode] Add Digits 加数字

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  10. [LeetCode] Different Ways to Add Parentheses 添加括号的不同方式

    Given a string of numbers and operators, return all possible results from computing all the differen ...

随机推荐

  1. Unity——射线系统

    Unity射线系统 Demo展示 UI+Physical射线测试: FPS自定义射线测试: UGUI射线工具 实现功能,鼠标点击UI,返回鼠标点击的UI对象: 需要使用到鼠标点击事件-PointerE ...

  2. Shadertoy 教程 Part 3 - 矩形和旋转

    Note: This series blog was translated from Nathan Vaughn's Shaders Language Tutorial and has been au ...

  3. 小白自制Linux开发板 十. NES游戏玩起来

    本篇基于我们制作的Debian文件系统而展开,而且我们这会玩一些高级的操作方式--用我们的小电脑进行程序编译.   所以本篇操作全部都在我们个的开发板上完成.   1. 开发环境搭建 首先安装gcc, ...

  4. Ubuntu 16.04 curl 安装 使用

    curl是利用URL语法在命令行方式显工作的开元文件传输工具. 安装 $ sudo apt install -y curl 使用 $ curl http://www.baidu.com 这是最简单的使 ...

  5. Luogu P3758 [TJOI2017]可乐 | 矩阵乘法

    题目链接 让我们先来思考一个问题,在一张包含$n$个点的图上,如何求走两步后从任意一点$i$到任意一点$j$的方案数. 我们用$F_p(i,j)$来表示走$p$步后从$i$到$j$的方案数,如果存储原 ...

  6. 使用Magisk+riru实现全局改机

    前言 提到全局改机,我们想到修改的不是修改Android源码就是利用Xposed改机,前者成本太高,后者只能修改Java层的数据不够彻底.magisk是Android平台上功能强大的工具,利用它可以随 ...

  7. Java 17 新功能介绍(LTS)

    点赞再看,动力无限.Hello world : ) 微信搜「程序猿阿朗 」. 本文 Github.com/niumoo/JavaNotes 和 未读代码博客 已经收录,有很多知识点和系列文章. Jav ...

  8. 【编译原理】LL1文法语法分析器

    上篇文章[编译原理]语法分析--自上向下分析 分析了LL1语法,文章最后说给出栗子,现在补上去. 说明: 这个语法分析器是利用LL1分析方法实现的. 预测分析表和终结符以及非终结符都是针对一个特定文法 ...

  9. oracle 使用union提示ORA-00907:缺少右括号

    在使用union的时候提示:ORA-00907:缺少右括号 此原因是因为在union的左边和右边都有order by,因此需要去掉一边的order by,保留一个即可. 例如: select * fr ...

  10. 14-1-Unsupervised Learning ---dimension reduction

    无监督学习(Unsupervised Learning)可以分为两种: 化繁为简 聚类(Clustering) 降维(Dimension Reduction) 无中生有(Generation) 所谓的 ...